Python for Introductory Statistics: Lab WorkbookXYZ Homework Edition

⇩ Download ▾

8.2 Binomial Probability Distribution

Watch demo video 1

Watch demo video 2

Lab 8.2.1

21% of all Chicagoans live in poverty. If 30 Chicagoans are randomly selected, find the probability that

  1. Exactly 1 of them live in poverty
  2. At most 4 of them live in poverty
  3. At least 4 of them live in poverty

view answer

Binomial Probability Plot

Example

Use the binomplot function below to plot a binomial distribution with n = 20 and probability of success is 0.70.

# binomial graph with n and p
def binomplot(n,p):
  from scipy import stats
  import numpy as np
  import matplotlib.pyplot as plt

  x = np.arange(0,n+1)
  y = stats.binom.pmf(x,n,p)
  plt.bar(x,y,width=0.2)

  plt.suptitle("Binomial Plot")
  plt.xlabel("x values")
  plt.ylabel("probability")

  return plt.show()

Lab 8.2.2

Use the binomplot function to plot a binomial distribution with n = 10 and probability of success is 0.60.

view answer

Adapted from Python for Introductory Statistics: Student's Lab Workbook, by Simon Aman (Truman College, City Colleges of Chicago), licensed under CC BY 4.0. Changes were made: reformatted as an accessible XYZ web edition with live in-browser code cells. License: CC-BY-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.