How can we calculate probability density of a histogram?

조회 수: 246 (최근 30일)
ishita agrawal
ishita agrawal 2017년 8월 19일
댓글: Image Analyst 2022년 6월 28일
Hello, I have a dataset containing hundreds of data points representing duration of events. I have plotted a histogram for this data set. I want to calculate probability density for the same. I want a plot having event duration at X-axis and probability density at Y-axis. I have attached histogram for which I want to calculate PD.

채택된 답변

the cyclist
the cyclist 2017년 8월 19일
편집: the cyclist 2017년 8월 19일

If you have version R2014b or later, you can use the histogram command, and specify the 'Normalization' property to be 'probability':

rng default
x = randn(1000,1);
h = histogram(x,'Normalization','probability');

h.Values will give you the density.

추가 답변 (3개)

Image Analyst
Image Analyst 2017년 8월 19일
Did you look in the documentation for histogram and see the normlization option:
'Normalization' Type of normalization
'count' (default) | 'probability' | 'countdensity' | 'pdf' | 'cumcount' | 'cdf'
  댓글 수: 3
Sajid Afaque
Sajid Afaque 2020년 6월 12일
what about for prior version.
i am using 2013b and i need probability distribution
Image Analyst
Image Analyst 2020년 6월 12일
Just divide your counts by either the number of counts in the highest bin, or by the sum of all bins, depending on how you define normalize.

댓글을 달려면 로그인하십시오.


Steven Lord
Steven Lord 2017년 8월 19일
Use the 'Normalization' option of the histogram function.

Mehri Mehrnia
Mehri Mehrnia 2022년 6월 27일
I have the same problem , just at I want to have same edges in both before normalization and after normalization.
I got an strange result!!!
  댓글 수: 1
Image Analyst
Image Analyst 2022년 6월 28일
Thanks for the announcement. If you have any questions, then attach your data and code to read it in with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by