ksdensity doesn't return a pdf which sums to 1 and has problems at the boundary

조회 수: 5 (최근 30일)
Mic
Mic 2015년 12월 14일
답변: dpb 2015년 12월 14일
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.

답변 (1개)

dpb
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
>>

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by