How to plot a probability density function on a histogram?
Show older comments
Hi,
I have a trouble plotting a normal density function with specific parameters on my histogram. I do not want to fit a normale distribution but I want to specify the parameters of the normal distribution myself.
Is this possible? And how?
Thanks in advance!
Accepted Answer
More Answers (1)
Shashank Prasanna
on 12 Mar 2013
Do you have the statistics toolbox?
If you do it is straight forward as this:
Plot your regular histogram and then:
hold on
x = -3:0.1:3;
Y = normpdf(x,0,1);
plot(x,Y)
In the above code, change your random variable x to roughly span +/- 3 sigma of your specified sigma around your mean. If you don't have the statistics toolbox you may have to code the normal pdf yourself or find something on MATLAB central.
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!