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

4 ビュー (過去 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.
  1 件のコメント
SARATH CHANDRA REDDY NALLALA
SARATH CHANDRA REDDY NALLALA 2022 年 9 月 7 日
Thanks Mr.Jeff Miller for clear explaination. This solves my query.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExploration and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by