ksdensity doesn't return a pdf which sums to 1 and has problems at the boundary
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
dpb
on 14 Dec 2015
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!