On Wed, Jan 15, 2014 at 1:17 PM, Matthew Rocklin <[email protected]<javascript:>
> 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.
Even worse with a slight modification:
>>> summation(binomial_dist*k, (k, 0, n))
TypeError: unsupported operand type(s) for *: 'NoneType' and 'Add'
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.