[R] density() returns a density function that does not add up to 1
Jonathan Li
jonqli at labs.agilent.com
Fri Aug 30 21:50:28 CEST 2002
Dear R users,
I ran into this curious problem:
> d <- rnorm(100)
> d.density <- density(d)
> sum( d.density$x * d.density$y)
[1] 2.517502
Admittedly the method of computing the mass under the density curve at
line 3 is crude.
But 2.5 is pretty far from 1, the value it should be.
I tried a few other dataset and got similar result. Am I missing
something obvious?
Or is the return of density() not supposed to be normalized?
Thanks in advance!
Jonathan
--
Jonathan Q. Li, PhD
Agilent Technologies Laboratory
Palo Alto, California, USA
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list