how to create two bell shape curves
3 次查看(过去 30 天)
显示 更早的评论
with the areas under these curves equal to 1, the same mean but different standard deviations. Thanks!
0 个评论
采纳的回答
Wayne King
2013-4-24
编辑:Wayne King
2013-4-24
Do you have the Statistics Toolbox?
x = -10:0.01:10;
y = normpdf(x,0,1);
y1 = normpdf(x,0,sqrt(2));
If you do not have the Statistics Toolbox, you can just use the definition of the Gaussian
f = @(x) 1/sqrt(2*pi)*exp(-x.^2/2);
integral(f,-10,10)
g = @(x) 1/sqrt(2*pi*2)*exp(-x.^2/4);
integral(g,-10,10)
To see the curves for above:
fcurv = 1/sqrt(2*pi)*exp(-x.^2/2);
gcurv = 1/sqrt(2*pi*2)*exp(-x.^2/4);
plot(x,fcurv); hold on;
plot(x,gcurv,'r')
0 个评论
更多回答(2 个)
Wayne King
2013-4-24
Hi Jenka, you cannot just do sum(y), you are forgetting about the very important dx in the integral
x = -10:0.01:10;
y = normpdf(x,0,1);
y1 = normpdf(x,0,sqrt(2));
dx = mean(diff(x));
sum(y*dx)
sum(y1*dx)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!