Negative values in kernel density estimation
Ältere Kommentare anzeigen
My input data vector 'x' has values ranging between 20 to 500 . when i use the command
[f1,y1]= ksdensity(x),
the out put values are negative. how is this possible?
2 Kommentare
the cyclist
am 30 Sep. 2022
Can you upload the data, or a sample that shows the issue? You can use the paper clip icon in the INSERT section of the toolbar.
Sunetra Chituru
am 30 Sep. 2022
Akzeptierte Antwort
Weitere Antworten (1)
Bala Tripura Bodapati
am 30 Sep. 2022
Hi Sunetra
It is my understanding that the output values returned by 'ksdensity' function are negative though the input vector contains positive values.
A 'normal kernel function' is the default function used by ‘ksdensity' function to return the probability density estimate. If your data has values near zero, you'll naturally get some overlap into the negative side as the individual kernels are summed.
As a workaround, the 'support' property can be set to 'positive' to restrict the density to positive values. The following code illustrates the suggested workaround:
x=20:10:500
[f1,y1]= ksdensity(x,'support','positive')
plot(y1,f1)
1 Kommentar
Sunetra Chituru
am 30 Sep. 2022
Kategorien
Mehr zu Gamma Distribution finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
