Error in the integration result
2 ビュー (過去 30 日間)
表示 古いコメント
Given the joint p.d.f.:

I'm trying to compute the expected value:
by the following code:

syms x y
pi = sym('pi');
fxy = (1/pi)*exp(-((x-1)^2+2*y*(x-1)+2*y^2));
Exy = int(int(x*y*fxy,x,-inf,inf),y,-inf,inf)
However, I got the following solution

I started to wonder if this function is not integrable in the first place. However, the answer was no. I computed the same integral by Wolfram Alpha (no offense...) and got the following result:

Am I doing something wrong in my code? Do you have any idea how to obtian the same result in MATLAB? I appreciate your help.
0 件のコメント
採用された回答
Paul
2022 年 2 月 23 日
編集済み: Paul
2022 年 2 月 23 日
Expected result after expand() and simplify() of fxy. Don't know why these operations are needed.
syms x y
Pi = sym(pi); % modified
fxy = (1/Pi)*exp(-((x-1)^2+2*y*(x-1)+2*y^2));
Exy = int(int(x*y*simplify(expand(fxy)),x,-inf,inf),y,-inf,inf)
Actually, the simplify() is not needed
syms x y
Pi = sym(pi); % modified
fxy = (1/Pi)*exp(-((x-1)^2+2*y*(x-1)+2*y^2));
Exy = int(int(x*y*expand(fxy),x,-inf,inf),y,-inf,inf)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!