How can we calculate probability density of a histogram?

270 Ansichten (letzte 30 Tage)
ishita agrawal
ishita agrawal am 19 Aug. 2017
Kommentiert: Image Analyst am 28 Jun. 2022
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.

Akzeptierte Antwort

the cyclist
the cyclist am 19 Aug. 2017
Bearbeitet: the cyclist am 19 Aug. 2017

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.

Weitere Antworten (3)

Image Analyst
Image Analyst am 19 Aug. 2017
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 Kommentare
Sajid Afaque
Sajid Afaque am 12 Jun. 2020
what about for prior version.
i am using 2013b and i need probability distribution
Image Analyst
Image Analyst am 12 Jun. 2020
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.

Melden Sie sich an, um zu kommentieren.


Steven Lord
Steven Lord am 19 Aug. 2017
Use the 'Normalization' option of the histogram function.

Mehri Mehrnia
Mehri Mehrnia am 27 Jun. 2022
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 Kommentar
Image Analyst
Image Analyst am 28 Jun. 2022
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:

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by