Estimate ksdensity values for large number of data points, e.g. 100000 values

조회 수: 5 (최근 30일)
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.
load MCMC_M1.mat;
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
Jeff Miller 2022년 9월 7일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Exploration and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by