I am trying to manipulate binomial distributions algebraically. Specifically, I would like to get the expected value and standard deviation of a random variable:
import sympy
import sympy.stats
from sympy import *
a = sympy.Symbol('a', integer=True)
W = sympy.stats.Binomial('W', a, sympy.S.Half, +1, -1)
print (W)
print (sympify(a).is_integer)
sympy.stats.E(W)
which outputs
W
True
then throws ValueError: a is not an integer
. I wonder what i am doing wrong here.