plot normal distribution plot on histogram of residuals

18 ビュー (過去 30 日間)
Tania
Tania 2014 年 7 月 24 日
コメント済み: Svenja Jetzinger 2024 年 4 月 24 日 9:16
Does anyone know how to do that? Would be great if it could look like that:
Thank you!!!

採用された回答

Wayne King
Wayne King 2014 年 7 月 24 日
Here is one way, I'll use Data as the residuals
Data = randn(1000,1); %just making up some junk data
binWidth = 0.7; %This is the bin width, you have to decide what makes sense
% for you
binCtrs = -3:0.7:3; %Bin centers, same thing, it depends on your data
n=length(Data);
counts = hist(Data,binCtrs);
prob = counts / (n * binWidth);
H = bar(binCtrs,prob,'hist');
set(H,'facecolor',[0.5 0.5 0.5]);
% get the N(0,1) pdf on a finer grid
hold on;
x = -3:.1:3;
y = normpdf(x,0,1); %requires Statistics toolbox
plot(x,y,'k','linewidth',2);
  1 件のコメント
Svenja Jetzinger
Svenja Jetzinger 2024 年 4 月 24 日 9:16
Is it possible, to get this curve automatically in the middle of each bar without values for bin width and bin centers?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by