필터 지우기
필터 지우기

how to create two bell shape curves

조회 수: 10 (최근 30일)
jenka
jenka 2013년 4월 24일
with the areas under these curves equal to 1, the same mean but different standard deviations. Thanks!

채택된 답변

Wayne King
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')

추가 답변 (2개)

jenka
jenka 2013년 4월 24일
Hi Wayne, yes, I tried both ways already. However, if you do sum(y) or sum(y1) to give you the are under the curve (or trapz(y)), it does not give you 1. That is why I posted here. I need the area under the curves to be equal to one. Any suggestions? Thanks

Wayne King
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)
  댓글 수: 1
jenka
jenka 2013년 4월 25일
But of course:) He-he....

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 General Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by