JuliaStats / KernelDensity.jl

Kernel density estimators for Julia
Other
177 stars 40 forks source link

Mass point to the right in the estimated density #21

Closed pkofod closed 8 years ago

pkofod commented 8 years ago

I am not sure if this is a bug, or my ignorance but running

using Distributions
using Gadfly
using KernelDensity

n = 300
dx = rand(TruncatedNormal(1., 20., 0, Inf),n)
x = cumsum(dx)

dx_kde = kde(dx)
dx_kde_midpoints = kde(dx, minimum(dx):maximum(dx)*2)

plot(x=1:n, y=x, Geom.line)
plot(x = dx_kde.x, y = dx_kde.density,Geom.line)
plot(x = dx_kde_midpoints.x, y = dx_kde_midpoints.density, Geom.line)

Gives the following two plots (in the same order as the code)

nomid midpoints

I really just wanted to truncate it to the left, which seems to work. No matter how high or low I set the upper limit in the kde(Array, Range) call, I get that jump in the end.

simonbyrne commented 8 years ago

See https://github.com/JuliaStats/KernelDensity.jl/issues/12#issuecomment-90646652

pkofod commented 8 years ago

Ah, okay, so I am basically seemingly the probability i remove to the left being added to the right. I get it