How to get the probability values from a histogram matlab

616 Views Asked by At

This a math/matlab question

I have a data set of angles ranging from -180 to 180

I then make a histogram of the data set using the code

histogram(angles)

I want to use the probabilities from the histogram for another plot for the equation

ln(probabilty of angle) = constant(angle) + constant 

The problem is that I don't know how to get the values for probabilities for the angles from -180 to 180 from the histogram.

I've read that I need to normalize my histogram but from there I am not sure what to do

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

The function hist() will normalise for you with its 3rd parameter:

x = rand(1000, 1)*360-180;
[probas, angles] = hist(x, -180:10:180, 1.0);
bar(angles, probas);

You might want to combine values of bin -180 and +180 Now angles and probas are available for other plots.