How to create a random variable whose parameters are themselves random variables in SymPy?

Viewed 556

I have a random variable Y whose distribution is Poisson with parameter that is itself a random variable X, which is Poisson with parameter 10.

How can I use SymPy to automatically calculate the covariance between X and Y? The code

from sympy.stats import *
x1 = Poisson("x1", 3)
x2 = Poisson("x2", x1)
print(covariance(x2,x1))

raises an error ValueError: Lambda must be positive The documentation is not clear to me on this matter, and playing around with the function given did not seem to work.

1 Answers
Related