1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Probability in Python

Exercise

Generating and plotting geometric distributions

In sports it is common for players to make multiple attempts to score points for themselves or their teams. Each single attempt can have two possible outcomes, scoring or not scoring. Those situations can be modeled with geometric distributions. With scipy.stats you can generate samples using the rvs() function for each distribution.

Consider the previous example of a basketball player who scores free throws with a probability of 0.3. Generate a sample, and plot it.

numpy has been imported for you with the standard alias np.

Instructions

100 XP
  • Import geom from scipy.stats, matplotlib.pyplot as plt, and seaborn as sns.
  • Generate a sample with size=10000 from a geometric distribution with a probability of success of 0.3.
  • Plot the sample generated.