Skip to content
Prev 23065 / 398502 Next

density() returns a density function that does not add up to 1

Dear R users,

I ran into this curious problem:
[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