[R] Question about density()

From: Dan Bolser <dmb_at_mrc-dunn.cam.ac.uk>
Date: Fri 04 Mar 2005 - 12:48:34 EST

If I integrate over the result of the density() funcion, is the result 1?

For example

x <- rnorm(1000)
plot(density(x))

Does the area under the curve I see sum to 1?

What I really want to know is if I can directly compare two particular curves, generated like this

x <- rnorm(1000)
plot(density(x))

a.seq <- seq(min(x),max(x),0.01)
lines(a.seq,dnorm(x=a.seq,mean=mean(x),sd=sd(x)))

I guess they are directly comparable if the area under density sums to one.

Is this correct?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Mar 04 12:55:49 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:40 EST