Scaling of Normal distribution - area under 'nompdf'

조회 수: 3 (최근 30일)
Arwel
Arwel 2024년 9월 24일
댓글: Star Strider 2024년 9월 24일
Hi,
I have a simple question which I can't quite see how to figure out and it's bugging me....
As I understand it, the area under 'normpdf' should be unity (as it's a probability). So, if I do the following, it seems to check out...
z = -10:10;
a = 3;
g = normpdf(z,0,a);
trapz(g)
..gives 0.999, which is fine.
However if I simply make a finer 'mesh' on my z array, so....
z = -10:0.5:10;
a = 3;
g = normpdf(z,0,a);
trapz(g)
..this time I get 1.9982.
Clearly, there's some scaling going on.
I though the whole point of 'normpdf' was that it was always normalised. What am I missing here? What is the area under the second curve not = 1?

채택된 답변

Star Strider
Star Strider 2024년 9월 24일
The trapz function can take the independent variable value as the fiirst argument (it otherwise assumes a step size of unity).
Doing that produces something similar to the correct value —
z = -10:0.5:10;
a = 3;
g = normpdf(z,0,a);
trapz(z,g)
ans = 0.9991
.
  댓글 수: 2
Arwel
Arwel 2024년 9월 24일
A thanks - that makes sense!
Star Strider
Star Strider 2024년 9월 24일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by