繁体   English   中英

归一化2直方图并绘图

[英]normalize 2 histogram and plot

我是Matlab的新手,我尝试根据如何在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

谢谢!

两个建议:

  1. 使用randn代替normrnd。
  2. 增加您尝试生成的数字数量。

码:

[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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM