Hi all,

A friend send me a question on why does this:

x<-rpois(100,1)
sum( hist(x)$density )

Gives out "2"

I tried this:

sum( hist(x, freq =T)$density )

It didn't help.

Then he came back with the following insight:

# with breaks
b<-c(0,0.9,1:8)
sum(hist(x,breaks=b)$density) # Much more then 2
# but if we add weights according to the interval length
sum(hist(x,breaks=b)$density * diff(b))
# it works



What do you think ?


Tal



----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Galili@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------

	[[alternative HTML version deleted]]

