On Thu, Jan 16, 2014 at 4:13 PM, F. B. <[email protected]> wrote:
> On Wed, Jan 15, 2014 at 1:17 PM, Matthew Rocklin <[email protected]> wrote:
>>
>> Discrete is the newest and least mature and could presumably use work.
>
>
> I tried to define a binomial distribution manually and do some calculations
> using summation:
>
> In [1]: n, k = var('n k', positive=True, integer=True)
>
> In [2]: p = var('p', positive=True)
>
> In [3]: binomial_dist = binomial(n, k)*p**k*(1-p)**(n-k)
>
> In [6]: summation(binomial_dist, (k, 0, n)).simplify()
> ⎧                                         │  1  │
> ⎪                1                  for p⋅│─────│ ≤ 1
> ⎪                                         │p - 1│
> ⎪
> ⎪  n
> ⎪ ____
> ⎪ ╲
> ⎨  ╲    k         -k         n ⎛n⎞
> ⎪   ╲  p ⋅(-p + 1)  ⋅(-p + 1) ⋅⎜ ⎟
> ⎪   ╱                          ⎝k⎠      otherwise
> ⎪  ╱
> ⎪ ╱
> ⎪ ‾‾‾‾
> ⎪k = 0
> ⎩
>
>
> This is technically correct, but is practically useless as a result.

So what is needed here is not a better summation module, but a better
way to simplify the relations in the Piecewise, which in a large part
boils down to the assumptions system. Here p/abs(p - 1) <= 1 can be
simplified. Interestingly, it seems it is not true if p > 0.5.

The summation module is just fine for this problem, though. It
computed the answer. There are many problems that it can't compute,
and for those we do need improvement. I don't know how many of them
come up in statistics. The so-called hypergeometric summations will be
the best in the current system, due to the meijerg algorithm.

>
> Even worse with a slight modification:
>
>>>> summation(binomial_dist*k, (k, 0, n))
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'Add'

Well this is obviously a bug. Can you report it?

Aaron Meurer

>
> I think that the summation module needs some further work.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to