Book Image

Mastering SciPy

By : Francisco Javier Blanco-Silva, Francisco Javier B Silva
Book Image

Mastering SciPy

By: Francisco Javier Blanco-Silva, Francisco Javier B Silva

Overview of this book

Table of Contents (16 chapters)
Mastering SciPy
About the Author
About the Reviewers


In the SciPy stack, we have two means for determining probability: a symbolic setting and a numerical setting. In this brief section, we are going to compare both with a sequence of examples.

For the symbolic treatment of random variables, we employ the module sympy.stats, while for the numerical treatment, we use the module scipy.stats. In both cases, the goal is the same—the instantiation of any random variable, and the following three kinds of operations on them:

  • Description of the probability distribution of a random variable with numbers (parameters).

  • Description of a random variable in terms of functions.

  • Computation of associated probabilities.

Let's observe several situations through the scope of the two different settings.

Symbolic setting

Let's start with discrete random variables. For instance, let's consider several random variables used to describe the process of rolling three 6-sided dice, one 100-sided dice, and the possible outcomes:

In [1]: from sympy import var; \...