search
Search
Publish
Guest 0reps
Thanks for the thanks!
close
Outline
chevron_left Probability Distributions
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
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
Doc Search
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Shrink
Navigate to
A
A
share
thumb_up_alt
bookmark
arrow_backShare
chevron_left Probability Distributions
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
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 librariesfrom scipy.stats import binomimport matplotlib.pyplot as plt# Specify n (number of trials) and p (probability of success)n = 4p = 0.5# Specifying the ranger_vals = list(range(n + 1))# Calculate the pmf values and store in a listpmf = [binom.pmf(r, n, p) for r in r_vals ]# Plotting a bar chart with Matplotlibplt.bar(r_vals, pmf)# Adding the axis labelsplt.xlabel(r'$x$')plt.ylabel(r'$p_X(x)$')plt.show() 
Edited by 0 others
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