Estimate ksdensity values for large number of data points, e.g. 100000 values
3 views (last 30 days)
SARATH CHANDRA REDDY NALLALA on 6 Sep 2022
Hi all, I want find the probability density function (pdf) values of a gaussian distributed data constituting 100000 values (obtained from MCMC sampling) using ksdensity function. But when I am trying I am getting absurd pdf values. The below is my code. The PDF values (PDF_s1, PDF_s2) calculated in this way are greater than 1. I am also attaching the original MCMC sample data. Please let me know how to solve this problem.
U = MCMC_M1;
s1 = U(:,1).';
s2 = U(:,2).';
PDF_s1 = ksdensity(s1,s1,'width',0.001);
PDF_s2 = ksdensity(s2,s2,'width',0.01);
Jeff Miller on 7 Sep 2022
It is a common mistake to think that PDF values should be less than 1. Actually, PDFs are defined in such a way that the area under them is 1. Your s1 values along the X axis only extend over very narrow range, so the PDF values on the Y axis have to be quite large to make the area under the PDF curve equal to 1 (range along X times average height on Y). It's the same for s2.