[R] Probabilities greather than 1 in HIST

2011-03-03 Thread jpmaroco
Dear all,
I am a newbie in R and could not find help on this problem. I am trying to
plot an histogram with probabilities in the y axis. This is the code I am
using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
xlab=Média, ylab=Probabilidade)
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)

The problem is that I am getting greater than 1 probabilities in the Y axis?
Is there a way to correct this?
Many thanks in advance.
Joao

--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread Jonathan P Daily
If you read ?hist, you will answer your own question.

The issue in your code is the parameter prob = T, which does nothing. By 
default, hist reports density.
--
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it.
 - Jubal Early, Firefly

r-help-boun...@r-project.org wrote on 03/03/2011 09:03:21 AM:

 [image removed] 
 
 [R] Probabilities greather than 1 in HIST
 
 jpmaroco 
 
 to:
 
 r-help
 
 03/03/2011 10:13 AM
 
 Sent by:
 
 r-help-boun...@r-project.org
 
 Dear all,
 I am a newbie in R and could not find help on this problem. I am trying 
to
 plot an histogram with probabilities in the y axis. This is the code I 
am
 using:
 
 #TLC uniform
 n=30
 mi=1; mx=6
 nrep=1000
 xbar=rep(0,nrep)
 for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
 hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
 xlab=Média, ylab=Probabilidade)
 curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)
 
 The problem is that I am getting greater than 1 probabilities in the Y 
axis?
 Is there a way to correct this?
 Many thanks in advance.
 Joao
 
 --
 View this message in context: http://r.789695.n4.nabble.com/
 Probabilities-greather-than-1-in-HIST-tp388p388.html
 Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:


Dear all,
I am a newbie in R and could not find help on this problem. I am  
trying to
plot an histogram with probabilities in the y axis. This is the code  
I am

using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
xlab=Média, ylab=Probabilidade)
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)

The problem is that I am getting greater than 1 probabilities in the  
Y axis?

Is there a way to correct this?


Despite the argument name, which I agree suggests that probabilities  
will be plotted, what is really described in the help page is that  
densities will be plotted, and densities may be greater than 1. You  
can suppress plotting of the y-axis, calculate the probabilities for  
each of the groups returned by hist,  and then use the axes function.


 xhist - hist(xbar,breaks=Sturges,plot=FALSE)
 yhist - xhist$counts/sum(xhist$counts)
 yhist
 [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001




Many thanks in advance.
Joao

--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread jpmaroco
Dear David,

Thanks for your prompt reply.

I see your point. But how can I get a histogram with relative frequencies? If I 
use

plot(xhist,yhist)

I get absolute frequencies in the Y axis.

Best,

Joao

 

From: David Winsemius [via R] 
[mailto:ml-node+619-1272092771-215...@n4.nabble.com] 
Sent: quinta-feira, 3 de Março de 2011 16:01
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST

 


On Mar 3, 2011, at 8:03 AM, jpmaroco wrote: 


 Dear all, 
 I am a newbie in R and could not find help on this problem. I am   
 trying to 
 plot an histogram with probabilities in the y axis. This is the code   
 I am 
 using: 
 
 #TLC uniform 
 n=30 
 mi=1; mx=6 
 nrep=1000 
 xbar=rep(0,nrep) 
 for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))} 
 hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n), 
 xlab=Média, ylab=Probabilidade) 
 curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red) 
 
 The problem is that I am getting greater than 1 probabilities in the   
 Y axis? 
 Is there a way to correct this? 


Despite the argument name, which I agree suggests that probabilities   
will be plotted, what is really described in the help page is that   
densities will be plotted, and densities may be greater than 1. You   
can suppress plotting of the y-axis, calculate the probabilities for   
each of the groups returned by hist,  and then use the axes function. 

  xhist - hist(xbar,breaks=Sturges,plot=FALSE) 
  yhist - xhist$counts/sum(xhist$counts) 
  yhist 
  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001 




 Many thanks in advance. 
 Joao 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t
  
 Sent from the R help mailing list archive at Nabble.com. 
 [[alternative HTML version deleted]] 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 


David Winsemius, MD 
Heritage Laboratories 
West Hartford, CT 

__ 
[hidden email] mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code. 



  _  

If you reply to this email, your message will be added to the discussion below:

http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html
 

To unsubscribe from Probabilities greather than 1 in HIST, click here 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==
 . 



--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote:


Dear David,

Thanks for your prompt reply.

I see your point. But how can I get a histogram with relative  
frequencies? If I use



plot(xhist,yhist)


I get absolute frequencies in the Y axis.


I do not know of any simple setting to do what you want only within  
hist.


I explained that you need to suppress the y axis ( read help(par) for  
how to do that, possibly with xaxt=n), calculate the values you  
desire, then add axis labeling at the locations on the density scale  
but with the probabilities you get from the calculations I illustrated.




Best,

Joao



From: David Winsemius [via R] [mailto:ml-node+619-1272092771-215...@n4.nabble.com 
]

Sent: quinta-feira, 3 de Março de 2011 16:01
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST




On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:



Dear all,
I am a newbie in R and could not find help on this problem. I am
trying to
plot an histogram with probabilities in the y axis. This is the code
I am
using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
xlab=Média, ylab=Probabilidade)
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)

The problem is that I am getting greater than 1 probabilities in the
Y axis?
Is there a way to correct this?



Despite the argument name, which I agree suggests that probabilities
will be plotted, what is really described in the help page is that
densities will be plotted, and densities may be greater than 1. You
can suppress plotting of the y-axis, calculate the probabilities for
each of the groups returned by hist,  and then use the axes function.


xhist - hist(xbar,breaks=Sturges,plot=FALSE)
yhist - xhist$counts/sum(xhist$counts)
yhist

 [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001





Many thanks in advance.
Joao

--
View this message in context: http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t 


Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



 _

If you reply to this email, your message will be added to the  
discussion below:


http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html

To unsubscribe from Probabilities greather than 1 in HIST, click  
here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA== 
 .




--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote:


Dear David,

Thanks for your prompt reply.

I see your point. But how can I get a histogram with relative  
frequencies? If I use



plot(xhist,yhist)


I get absolute frequencies in the Y axis.


In my earlier reply I meant to type yaxt=n.

--
David.


Best,

Joao



From: David Winsemius [via R] [mailto:ml-node+619-1272092771-215...@n4.nabble.com 
]

Sent: quinta-feira, 3 de Março de 2011 16:01
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST




On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:



Dear all,
I am a newbie in R and could not find help on this problem. I am
trying to
plot an histogram with probabilities in the y axis. This is the code
I am
using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
xlab=Média, ylab=Probabilidade)
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)

The problem is that I am getting greater than 1 probabilities in the
Y axis?
Is there a way to correct this?



Despite the argument name, which I agree suggests that probabilities
will be plotted, what is really described in the help page is that
densities will be plotted, and densities may be greater than 1. You
can suppress plotting of the y-axis, calculate the probabilities for
each of the groups returned by hist,  and then use the axes function.


xhist - hist(xbar,breaks=Sturges,plot=FALSE)
yhist - xhist$counts/sum(xhist$counts)
yhist

 [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001





Many thanks in advance.
Joao

--
View this message in context: http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t 


Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



 _

If you reply to this email, your message will be added to the  
discussion below:


http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html

To unsubscribe from Probabilities greather than 1 in HIST, click  
here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA== 
 .




--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread Martyn Byng
Hi,

Does

xx = rnorm(100)
hist(xx,freq=FALSE)
curve(dnorm,add=TRUE)

give you what you want?

Martyn
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of David Winsemius
Sent: 03 March 2011 17:00
To: jpmaroco
Cc: r-help@r-project.org
Subject: Re: [R] Probabilities greather than 1 in HIST


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote:

 Dear David,

 Thanks for your prompt reply.

 I see your point. But how can I get a histogram with relative  
 frequencies? If I use

 plot(xhist,yhist)

 I get absolute frequencies in the Y axis.

In my earlier reply I meant to type yaxt=n.

-- 
David.

 Best,

 Joao



 From: David Winsemius [via R] 
 [mailto:ml-node+619-1272092771-215...@n4.nabble.com 
 ]
 Sent: quinta-feira, 3 de Março de 2011 16:01
 To: jpmaroco
 Subject: Re: Probabilities greather than 1 in HIST




 On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:


 Dear all,
 I am a newbie in R and could not find help on this problem. I am
 trying to
 plot an histogram with probabilities in the y axis. This is the code
 I am
 using:

 #TLC uniform
 n=30
 mi=1; mx=6
 nrep=1000
 xbar=rep(0,nrep)
 for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
 hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
 xlab=Média, ylab=Probabilidade)
 curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)

 The problem is that I am getting greater than 1 probabilities in the
 Y axis?
 Is there a way to correct this?


 Despite the argument name, which I agree suggests that probabilities
 will be plotted, what is really described in the help page is that
 densities will be plotted, and densities may be greater than 1. You
 can suppress plotting of the y-axis, calculate the probabilities for
 each of the groups returned by hist,  and then use the axes function.

 xhist - hist(xbar,breaks=Sturges,plot=FALSE)
 yhist - xhist$counts/sum(xhist$counts)
 yhist
  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001




 Many thanks in advance.
 Joao

 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
  
  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t
  
 
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]

 __
 [hidden email] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 [hidden email] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



  _

 If you reply to this email, your message will be added to the  
 discussion below:

 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html

 To unsubscribe from Probabilities greather than 1 in HIST, click  
 here 
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==
  
  .



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
 Sent from the R help mailing list archive at Nabble.com.
   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread Dennis Murphy
Hi:

Here's an example:

x - rnorm(300)
hist(x, breaks = 15, yaxt = 'n', ylab = 'Relative frequency')
axis(2, at = seq(0, 50, by = 10), labels = round(seq(0, 50, by =
10)/length(x), 3))

HTH,
Dennis

On Thu, Mar 3, 2011 at 8:29 AM, jpmaroco jpmar...@gmail.com wrote:

 Dear David,

 Thanks for your prompt reply.

 I see your point. But how can I get a histogram with relative frequencies?
 If I use

 plot(xhist,yhist)

 I get absolute frequencies in the Y axis.

 Best,

 Joao



 From: David Winsemius [via R] [mailto:
 ml-node+619-1272092771-215...@n4.nabble.com]
 Sent: quinta-feira, 3 de Março de 2011 16:01
 To: jpmaroco
 Subject: Re: Probabilities greather than 1 in HIST




 On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:


  Dear all,
  I am a newbie in R and could not find help on this problem. I am
  trying to
  plot an histogram with probabilities in the y axis. This is the code
  I am
  using:
 
  #TLC uniform
  n=30
  mi=1; mx=6
  nrep=1000
  xbar=rep(0,nrep)
  for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
  hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n),
  xlab=Média, ylab=Probabilidade)
  curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)
 
  The problem is that I am getting greater than 1 probabilities in the
  Y axis?
  Is there a way to correct this?


 Despite the argument name, which I agree suggests that probabilities
 will be plotted, what is really described in the help page is that
 densities will be plotted, and densities may be greater than 1. You
 can suppress plotting of the y-axis, calculate the probabilities for
 each of the groups returned by hist,  and then use the axes function.

   xhist - hist(xbar,breaks=Sturges,plot=FALSE)
   yhist - xhist$counts/sum(xhist$counts)
   yhist
  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001




  Many thanks in advance.
  Joao
 
  --
  View this message in context:
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t
 
  Sent from the R help mailing list archive at Nabble.com.
  [[alternative HTML version deleted]]
 
  __
  [hidden email] mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 [hidden email] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



   _

 If you reply to this email, your message will be added to the discussion
 below:


 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html

 To unsubscribe from Probabilities greather than 1 in HIST, click here 
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==
 .



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
 Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread jpmaroco
Hi Martin,

No, I get frequencies greather than 1.

 

See the code:

#TLC uniform

n=30

mi=1; mx=6

nrep=1000

xbar=rep(0,nrep)

for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}

hist(xbar, freq=FALSE)

#hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n), 
xlab=Média, ylab=Probabilidade)

curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red)

 

Thanks anyway

Best

Jº

 

From: Martyn Byng [via R] 
[mailto:ml-node+757-242386738-215...@n4.nabble.com] 
Sent: quinta-feira, 3 de Março de 2011 17:12
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST

 

Hi, 

Does 

xx = rnorm(100) 
hist(xx,freq=FALSE) 
curve(dnorm,add=TRUE) 

give you what you want? 

Martyn 
-Original Message- 
From: [hidden email] [mailto:[hidden email]] On Behalf Of David Winsemius 
Sent: 03 March 2011 17:00 
To: jpmaroco 
Cc: [hidden email] 
Subject: Re: [R] Probabilities greather than 1 in HIST 


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote: 


 Dear David, 
 
 Thanks for your prompt reply. 
 
 I see your point. But how can I get a histogram with relative   
 frequencies? If I use 
 
 plot(xhist,yhist) 
 
 I get absolute frequencies in the Y axis. 


In my earlier reply I meant to type yaxt=n. 

-- 
David. 


 
 Best, 
 
 Joao 
 
 
 
 From: David Winsemius [via R] [mailto:[hidden email] 
 ] 
 Sent: quinta-feira, 3 de Março de 2011 16:01 
 To: jpmaroco 
 Subject: Re: Probabilities greather than 1 in HIST 
 
 
 
 
 On Mar 3, 2011, at 8:03 AM, jpmaroco wrote: 
 
 
 Dear all, 
 I am a newbie in R and could not find help on this problem. I am 
 trying to 
 plot an histogram with probabilities in the y axis. This is the code 
 I am 
 using: 
 
 #TLC uniform 
 n=30 
 mi=1; mx=6 
 nrep=1000 
 xbar=rep(0,nrep) 
 for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))} 
 hist(xbar,prob=TRUE,breaks=Sturges,xlim=c(1,6),main=paste(n =,n), 
 xlab=Média, ylab=Probabilidade) 
 curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col=red) 
 
 The problem is that I am getting greater than 1 probabilities in the 
 Y axis? 
 Is there a way to correct this? 
 
 
 Despite the argument name, which I agree suggests that probabilities 
 will be plotted, what is really described in the help page is that 
 densities will be plotted, and densities may be greater than 1. You 
 can suppress plotting of the y-axis, calculate the probabilities for 
 each of the groups returned by hist,  and then use the axes function. 
 
 xhist - hist(xbar,breaks=Sturges,plot=FALSE) 
 yhist - xhist$counts/sum(xhist$counts) 
 yhist 
  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001 
 
 
 
 
 Many thanks in advance. 
 Joao 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t

  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t
  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=tby-user=t

  
 Sent from the R help mailing list archive at Nabble.com. 
 [[alternative HTML version deleted]] 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 
 
 David Winsemius, MD 
 Heritage Laboratories 
 West Hartford, CT 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 
 
 
  _ 
 
 If you reply to this email, your message will be added to the   
 discussion below: 
 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html
  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html?by-user=t
  
 
 To unsubscribe from Probabilities greather than 1 in HIST, click   
 here 
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code
  
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==by-user=t
  node=388code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==  
  . 
 
 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
  
 http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html?by-user=t
  
 Sent from the R help mailing list archive at Nabble.com. 
 [[alternative HTML version deleted]] 
 
 __ 
 [hidden email] mailing list 
 https