Integrate is adding a tiny imaginary error to an easy result. Why? And how can I stop it?
gauMix[x_, means_, vars_] :=
Total[(E^-(((x - means)^2)/(2*vars)))/Sqrt[2*Pi*vars]]/Length[means];
means = {-7, 7};
vars = {6, 6.5};
f[x_] := gauMix[x, means, vars];
fxx = Integrate[f[x]*(x^2), {x, -Infinity, Infinity}]
(* 55.25 - 3.16199*10^-14 I *)
If I change vars to {6,6} everything is fine. And NIntegrate hasn't made this error yet, that I've seen. But I want to use Integrate instead of NIntegrate so I can get an exact, analytical answer.
Comments
Post a Comment