How to fit a gaussian distribution curve on a bar diagram?

22 ビュー (過去 30 日間)
Raushan
Raushan 2022 年 9 月 27 日
コメント済み: Raushan 2022 年 9 月 27 日
Hello guys!
I have pdf of sum of two dice like data = [1/36,2/36,3/36,4/36,5/36,6/36,5/36,4/36,3/36,2/36,1/36] and sum =[2,3,4,5,6,7,8,9,10,11,12] I have darwn a bar chart using data. now I want to fit a normal distribution curve over this bar chart. But when I did it normal curve is coming out very narrow how can I spread it so that all the bar will come under normal curve. here is my plots
can you please help me to figure out this.
any help will be appreciated!
  2 件のコメント
Matt J
Matt J 2022 年 9 月 27 日
We don't know what you did to obtain the curve.
Raushan
Raushan 2022 年 9 月 27 日
here is my script
y =[1/36,2/36,3/36,4/36,5/36,6/36,5/36,4/36,3/36,2/36,1/36];
bar(y)
hold on
p = -3:0.01:3;
q = normpdf(p,0,0.1);
plot(p,q)
after doing this my bar diagram is not coming under the curve

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

採用された回答

Chunru
Chunru 2022 年 9 月 27 日
編集済み: Chunru 2022 年 9 月 27 日
p = [1/36,2/36,3/36,4/36,5/36,6/36,5/36,4/36,3/36,2/36,1/36];
xsum =[2,3,4,5,6,7,8,9,10,11,12] ;
bar(xsum, p)
mu = sum(p.*xsum)
mu = 7.0000
sigma2 = sum(p.*(xsum -mu).^2)
sigma2 = 5.8333
hold on
plot(0:.1:13, normpdf(0:.1:13, mu, sqrt(sigma2)), 'r-')
  5 件のコメント
Chunru
Chunru 2022 年 9 月 27 日
Yes. Just change the x grid as updated above.
Raushan
Raushan 2022 年 9 月 27 日
Thank you very much it works!!

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

その他の回答 (0 件)

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by