MATLAB: How can we calculate probability density of a histogram

histogramprobability density

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.

Best Answer

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.

Related Question