This is a reply to Luke Spadavecchia's question about hist densities.
If you want to construct a histogram where the bar heights are the
percentage of observations in the intervals you can use this code:
x-rnorm(n=5000,mean=1.5,sd=0.25)
h-hist(x)
h$density-h$counts/sum(h$counts)
Hi there,
I was wondering why
x-rnorm(n=5000,mean=1.5,sd=0.25)
h-hist(x)
sum(h$density)
[1] 10
I thought the integral of the histogram should be one? These seems
strange to me, or am I being silly...
Regards Luke Spadavecchia
PS. I'm using R 2.5.1 on Mac OSX
On Fri, 21 Mar 2008, Luke Spadavecchia wrote:
Hi there,
I was wondering why
x-rnorm(n=5000,mean=1.5,sd=0.25)
h-hist(x)
sum(h$density)
[1] 10
I thought the integral of the histogram should be one? These seems
strange to me, or am I being silly...
The integral is not a sum of heights
3 matches
Mail list logo