[SciPy-User] generic expectation operator
nicky van foreest
Thu Aug 23 13:09:24 CDT 2012
> oversight to add it, I guess.
> can be added and it can delegate like in the other methods. PR welcome.
oops. I saw this request coming. While it is trivial to implement
(nearly a copy paste from the other examples in rv_frozen), I have to
admit that working with git takes me a considerable amount of time, as
I hardly use it.
> (I almost never work with frozen distribution and didn't see this.)
Is there a specific reason for this? I find it very convenient.
For the moment I solve the problem with the expectation with this function:
def expect(X, f, lb, ub):
if hasattr(X, 'dist'):
return X.dist.expect(f, lb = lb, ub = ub)
return X.expect(f, lb = lb, ub = ub)
Like this I can pass frozen distributions and the ones that I make
with rv_discrete. As your suggestion above is not yet part of
standard scipy, I 'll use this function to show my students how
convenient python is.
More information about the SciPy-User