我是matlab的新手,我试图根据How to normalize a histogram in MATLAB?规范化两个正态分布,但我不能。有人可以告诉我如何规范下面的两个正态分布:
[f,x]=hist(normrnd(25,2.5),50);%# create histogram from a normal distribution.
g=1/sqrt(2*pi)*exp(-0.5*x.^2);%# pdf of the normal distribution
figure(1)
bar(x,f/trapz(x,f));hold on
plot(x,g,'r');hold off
谢谢!
答案 0 :(得分:1)
两个建议:
代码:
[f,x]=hist(randn(10000,2.5),50);%# create histogram from a normal distribution.
g=1/sqrt(2*pi)*exp(-0.5*x.^2);%# pdf of the normal distribution
figure(1)
bar(x,f/trapz(x,f));hold on
plot(x,g,'r');hold off