September 2014
Intermediate to advanced
512 pages
12h 39m
English
SymPy includes a module named stats that lets us create and manipulate random variables. This is useful when we work with probabilistic or statistical models; we can compute symbolic expectancies, variances probabilities, and densities of random variables.
In [1]: from sympy import *
from sympy.stats import *
init_printing()X and Y, with six faces each:In [2]: X, Y = Die('X', 6), Die('Y', 6)Eq operator) or inequalities:In [3]: P(Eq(X, 3)) Out[3]: 1/6 In [4]: P(X>3) Out[4]: 1/2
In [5]: P(X>Y) Out[5]: ...
Read now
Unlock full access