ksdensity doesn't return a pdf which sums to 1 and has problems at the boundary
4 次查看(过去 30 天)
显示 更早的评论
I'm using ksdensity (with optimal bw) to estimate a pdf, but when I sum up the single entries I get 0.49. Shouldn't the sum be 1? Also, it returns zeros at the boundaries. How to correct for the zeros? Thank you.
0 个评论
回答(1 个)
dpb
2015-12-14
Not necessarily, no. It'll depend on the range of the underlying estimated pdf covered in the input range of the data as well as you need to normalize the summation to produce an integral. Try the optional 'cdf' function with ksdensity; there's an example in the doc.
As an illustration, consider the following --
>> sum(normpdf(-1:0.01:1))/100
ans =
0.6851
>> sum(normpdf(-2:0.01:2))/100
ans =
0.9550
>>
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!