How to plot a probability density function on a histogram?
조회 수: 9 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
Image Analyst
2013년 3월 12일
Use bar() or plot() to plot the actual histogram. Then use "hold on" and use plot() to plot the theoretical distribution.
bar(values, counts);
hold on;
plot(myNormalDistribution, 'r-', 'LineWidth', 3);
grid on;
댓글 수: 0
추가 답변 (1개)
Shashank Prasanna
2013년 3월 12일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!