簡體   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