2012-05-31 127 views

回答

7
histfit(data); 

將數據繪製爲直方圖,並顯示最佳擬合高斯平滑曲線。

[mu, sigma] = normfit(data); 
pd = fitdist(data,'normal'); 

會給平均值(MU)和相同的數據集,其用於通過histfit生成擬合曲線的標準偏差(Sigma)中。

如果你這樣做edit histfit你可以看看它,看到了正態曲線的高度發現正常的曲線和直方圖中的區域下等同的面積,查找代碼周圍

% Normalize the density to match the total area of the histogram 
xd = get(hh,'Xdata');    % Gets the x-data of the bins. 
rangex = max(xd(:)) - min(xd(:)); % Finds the range of this data. 
binwidth = rangex/nbins;   % Finds the width of each bin. 
area = n * binwidth; 
y = area * pdf(pd,x); 

以獲得關於做這部分縮放的更多提示。