필터 지우기
필터 지우기

How can I find the integral of normpdf(X,1,0) from -inf to inf?

조회 수: 2 (최근 30일)
may
may 2013년 6월 4일
댓글: Colin 2019년 3월 17일
How can I find the integral of normpdf(x,1,0) from -inf to inf?
The followings did not work:
F = @(x)normpdf(x, 0, 1);
Q = quad(F,-Inf,Inf);
---------
syms x;
int('normpdf(x,0,1)',-inf,inf)

답변 (2개)

Wayne King
Wayne King 2013년 6월 4일
F = @(x)normpdf(x, 0, 1);
Q = integral(F,-Inf,Inf);
  댓글 수: 5
may
may 2013년 6월 4일
What is the difference between integral and int?
Colin
Colin 2019년 3월 17일
F = @(x)normpdf(x, 0, 1);
Q = integral(F,-Inf,Inf);
This works nicely, but this:
F = @(x)normpdf(x, 350, 20);
Q = integral(F,-Inf,Inf);
gives
Q = 3.4540e-29
Seems likes it's not very robust.

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


Wayne King
Wayne King 2013년 6월 4일
편집: Wayne King 2013년 6월 4일
integral() was introduced in R2012a. It is used to numerically evaluate an integral, not symbolically and integral() can be unused on unbounded sets like (-Inf,Inf)
Again, in your case you can use quad() far short of (-Inf,Inf) and get 1.
  댓글 수: 5
may
may 2013년 6월 5일
Thank you all for your replies.
I upgraded my MATLAB to 2013, so now I can use "Integral"
Now I want to find the following integral:
F = @(x)(normpdf(x, 0, 1)*normcdf(x, 0.2, 1.5)*normcdf(x, 0.2, 0.5));
Q = integral(F,-Inf,Inf);
But I get the following error:
Error using *
Inner matrix dimensions must agree.
Do you know what should I do to fix it?
may
may 2013년 6월 5일
I think I fixed it
F = @(x)normpdf(x, 0, 1)
G= @(x)normcdf(x, 0.2,1.5)
H= @(x)normcdf(x, 0.2,0.5)
Q = integral(@(x)F(x).*G(x).*H(x),-Inf,Inf)

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by