Skip to content
Prev 199203 / 398506 Next

Density estimate with bounds

Hi Gavin,

I have already played around with from, to. It seems, however, that
from=0, to=1 simply crops the density curve at 0 and 1:

x = runif(1000)
fx = density(x)
fxc = density(x, from=0, to=1)
plot(fx)
lines(fxc, col=2, lwd=2)

Unfortunately, this 'cropped' density does not integrate to 1
anymore:

 > sum(fx$y)*(fx$x[2]-fx$x[1])
[1] 1.000934
 > sum(fxc$y)*(fxc$x[2]-fxc$x[1])
[1] 0.9539383

I am naively thinking about a density estimator which is aware
of such bounds.

Best wishes,

Justine

-------- Original-Nachricht --------