search
Search
Publish
menu
menu search toc more_vert
Robocat
Guest 0reps
Thanks for the thanks!
close
Outline
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
help Ask a question
Share on Twitter
search
keyboard_voice
close
Searching Tips
Search for a recipe: "Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
icon_star
Doc Search
icon_star
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to
A
A
share
thumb_up_alt
bookmark
arrow_backShare
Twitter
Facebook
thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings

Binomial Distribution

Probability and Statistics
chevron_right
Probability Distributions
schedule Mar 10, 2022
Last updated
local_offer
Tags
tocTable of Contents
expand_more

The binomial distribution is a discrete distribution which models the number of successes in a fixed number of independent trials. It can be described by two parameters:

$n$ = number of trials

$p$ = probability of success

The following conditions apply for the binomial distribution to be appropriate:

  • For each trial there are only 2 outcomes: success or failure

  • Each trial is independent (result of one trial does not affect the result of another)

  • The number of trials is fixed: $n$

  • Each trial has the same probability of success: $p$

Formula

The binomial formula is represented as follows:

$$\mathbb{P}(X=x)= \tbinom{n}{x}p^xq^{n-x}$$

where:

$n$ = number of trials

$p$ = probability of success

$q$ = probability of failure = $1 - p$

Example

Let us toss a coin four times. We define random variable $X$ as the number of heads obtained from the four tosses. Assume that this is a fair coin and the probability of getting a heads is 0.5 and tails is 0.5.

To find the probability of getting exactly 2 heads (i.e. $\mathbb{P}(X=2)$):

$$\begin{align*} \mathbb{P}(X=2) &= \tbinom{4}{2}0.5^20.5^{4-2}\\ &= 0.375 \end{align*}$$

By plotting the probability mass function, we can see the probability of getting the various numbers of heads in our four tosses of the coin:

As per our calculation from the formula, we can see that the probability of getting exactly 2 heads in our 4 tosses is 0.375.

The above graph can be plotted using Python's SciPy and Matplotlib libraries:

# Import the relevant libraries
from scipy.stats import binom
import matplotlib.pyplot as plt

# Specify n (number of trials) and p (probability of success)
n = 4
p = 0.5

# Specifying the range
r_vals = list(range(n + 1))

# Calculate the pmf values and store in a list
pmf = [binom.pmf(r, n, p) for r in r_vals ]

# Plotting a bar chart with Matplotlib
plt.bar(r_vals, pmf)

# Adding the axis labels
plt.xlabel(r'$x$')
plt.ylabel(r'$p_X(x)$')

plt.show()
robocat
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
A modern learning experience for data science and analytics