Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


LoginGet Started
← Back to Lessons
Edit on Github
Open in Colab

Plotting Binomial Distribution with Python

Plotting Distributions

The fourth row of our sennet table contained the values:

1 4 6 4 11 ~ 4 ~ 6 ~ 4 ~ 1

We can draw a plot of this using bars to represent the counts of each outcome.

In [ ]:
bars = ['no white', 'one white', 'two white', 'three white', 'four white']
counts = [1, 4, 6, 4, 1]
In [ ]:
plt.bar(bars, counts)
plt.title('Counts for each outcome with four two sided sticks');

Using this plot, we come back to the problem of determining the probability of a given outcome or outcomes. Here, we can interpret this probability as the relative area of a given bar to the overall count. For example, we consider each bar having width of one unit, and height of the count. Thus, we have a total area of:

TOTAL AREA=1+4+6+4+1=16\textbf{TOTAL AREA} = 1 + 4 + 6 + 4 + 1 = 16

This is the total number of possible outcomes. Thus, determining the probability of a specific outcome is as simple as dividing the total area of our bars by the area under the event of interest.

P(two white)=area of bar for two whitetotal area=616P(\text{two white}) = \frac{\text{area of bar for two white}}{\text{total area}} = \frac{6}{16}

Problems

  1. Use the plot above to determine the probability of zero white sticks.
  2. Use the plot above to determine the probability of one white stick?
  3. What is the probability of one, two, or three white sticks and how do we use the graph to determine this.