4Geeks logo
4Geeks logo

Bootcamps

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.

Academy

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.

Full-Stack Software Developer - 16w

Data Science and Machine Learning - 16 wks

Search from all Lessons


LoginGet Started
← Back to Lessons

Weekly Coding Challenge

Every week, we pick a real-life project to build your portfolio and get ready for a job. All projects are built with ChatGPT as co-pilot!

Start the Challenge

Podcast: Code Sets You Free

A tech-culture podcast where you learn to fight the enemies that blocks your way to become a successful professional in tech.

Listen the podcast
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.