[SciPy-User] generic expectation operator

josef.pktd@gmai... josef.pktd@gmai...
Thu Aug 23 14:07:21 CDT 2012


On Thu, Aug 23, 2012 at 2:09 PM, nicky van foreest <vanforeest@gmail.com> wrote:
> Hi Josef,
>
>> oversight to add it, I guess.
>
> Ok.
>
>>
>> can be added and it can delegate like in the other methods.  PR welcome.
>> frozen_dist.dist.expect(..)
>
> 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'm using mostly git gui so I can keep the number of git commands,
sub-commands and options that I have to remember or to look up to a
small number. Then it's ok.

>
>>
>> (I almost never work with frozen distribution and didn't see this.)
>
> Is there a specific reason for this? I find it very convenient.

habit, unnecessary detour and useless for fitting.

>
> 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)
>     else:
>         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.

If you run into problems with the discrete expect, then please report
them or file a ticket (if not a PR).
I have no idea how much usage it has seen, and it's based on a
truncated sum, that has problems in some cases (edge cases or cases
where tails are important).

Josef

>
> Nicky
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user


More information about the SciPy-User mailing list