MATLAB:如何解决这个积分以获得期望值?
MATLAB: how to solve this integral for getting expected value?
我想求解 f(x)
和 x=[x1,x2]
的期望值服从均匀分布。我试过这个:
syms x r d x1 x2;
f=2*x*acos(x^2-d^2/2*x*(r+d)+d/x)*(1/sqrt(2*pi))*exp(-x^2/2);
int(f,'x',x1,x2)
我需要一种参数化方法。但是 Matlab 未能以符号格式解决此积分问题。有什么解决办法吗?
如果要用数值来做,需要用到数值函数:integral
示例:
d=40;r=15;
%define f as anonymous function
f=@(x)2.*x.*acos(x.^2-d^2./2.*x.*(r+d)+d./x).*(1/sqrt(2*pi)).*exp(-x.^2/2);
integral(f,40,70)
这给了我 0,(因为它是 0),但是如果你尝试,例如:
d=4;r=2
integral(f,0,10)
ans =
2.4036 - 3.3624i
我想求解 f(x)
和 x=[x1,x2]
的期望值服从均匀分布。我试过这个:
syms x r d x1 x2;
f=2*x*acos(x^2-d^2/2*x*(r+d)+d/x)*(1/sqrt(2*pi))*exp(-x^2/2);
int(f,'x',x1,x2)
我需要一种参数化方法。但是 Matlab 未能以符号格式解决此积分问题。有什么解决办法吗?
如果要用数值来做,需要用到数值函数:integral
示例:
d=40;r=15;
%define f as anonymous function
f=@(x)2.*x.*acos(x.^2-d^2./2.*x.*(r+d)+d./x).*(1/sqrt(2*pi)).*exp(-x.^2/2);
integral(f,40,70)
这给了我 0,(因为它是 0),但是如果你尝试,例如:
d=4;r=2
integral(f,0,10)
ans =
2.4036 - 3.3624i