[SciPy-User] generic expectation operator

nicky van foreest vanforeest@gmail....
Thu Aug 23 11:36:00 CDT 2012


Hi Josef,

Thanks for your answers.

>>>         return scipy.integrate.quad(lambda x: x*g(x), X.dist.a, X.dist.b)

>>> X = stats.norm(3,sqrt(3))
>>> print E(sqrt, X)

> I don't know why this works, sqrt of a normal distributed random
> variable has lots of nans (or complex numbers)

You are right, it shouldn't work. The point is that my code above is
this: lambda x: x*g(x), while it should have been lambda x: f(x)*g(x).

I'll give expect a try.

Nicky


More information about the SciPy-User mailing list