Geometric distributions

Foundations of Probability in Python

Alexander A. Ramírez M.

CEO @ Synergy Vision

Geometric modeling

Basketball player free throw

Foundations of Probability in Python

Geometric parameter

Geometric distribution probability mass function plot

Model for a basketball player with probability 0.3 of scoring.

Geometric distribution probability mass function plot

We can model a grizzly bear that has a 0.033 probability of catching a salmon.

Foundations of Probability in Python

Probability mass function (pmf)

Geometric distribution probability mass function plot

In Python we code this as follows:

# Import geom
from scipy.stats import geom
# Calculate the probability mass 
# with pmf
geom.pmf(k=30, p=0.0333)
0.02455102908739612

p parameter specifies probability of success.

Foundations of Probability in Python

Cumulative distribution function (cdf)

Geometric distribution cumulative distribution function

Geometric distribution cumulative distribution function

# Calculate cdf of 4
geom.cdf(k=4, p=0.3)
0.7598999999999999
Foundations of Probability in Python

Survival function (sf)

Geometric distribution survival function

$$ $$

# Calculate sf of 2
geom.sf(k=2, p=0.3)
0.49000000000000005
Foundations of Probability in Python

Percent point function (ppf)

Geometric distribution percent point function

$$ $$

# Calculate ppf of 0.6
geom.ppf(q=0.6, p=0.3)
3.0
Foundations of Probability in Python

Sample generation (rvs)

# Import poisson, matplotlib.pyplot, and seaborn
from scipy.stats import geom
import matplotlib.pyplot as plt
import seaborn as sns
# Create the sample using geom.rvs()
sample = geom.rvs(p=0.3, size=10000, random_state=13)
# Plot the sample
sns.distplot(sample, bins = np.linspace(0,20,21), kde=False)
plt.show()
Foundations of Probability in Python

Sample generation (rvs) (Cont.)

Geometric distribution sample histogram

Foundations of Probability in Python

Let's go try until we succeed!

Foundations of Probability in Python

Preparing Video For Download...