Error in the integration result
1 次查看(过去 30 天)
显示 更早的评论
Given the joint p.d.f.:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/904550/image.png)
I'm trying to compute the expected value:
by the following code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/904555/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/904560/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/904565/image.png)
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!