Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Binomial Distribution | Commonly Used Discrete Distributions
Probability Theory Basics
course content

Зміст курсу

Probability Theory Basics

Probability Theory Basics

1. Basic Concepts of Probability Theory
2. Probability of Complex Events
3. Commonly Used Discrete Distributions
4. Commonly Used Continuous Distributions
5. Covariance and Correlation

Binomial Distribution

Discrete distribution describes the experiment with a finite number of possible outcomes.

Imagine a stochastic experiment with only two possible outcomes: success and failure.
A successful result for us appears with a probability of p, respectively, and an unsuccessful result appears with a probability of 1-p.
Such an experiment is called Bernoulli trial. A sequence of several independent Bernoulli trials is called a Bernoulli process.
Assume that we are flipping a coin and want to have a tail. Such a flip will be a Bernoulli trial. If we flip the coin 2 or more times, it will be the Bernoulli process.

We can conduct the Bernoulli process in Python using the .rvs() method of the scipy.stats.bernoulli class.
Assume we have an asymmetrical coin in which the probabilities of getting a head and a tail are unequal. We can simulate 10 tosses of such coin using the following code:

12345678
from scipy.stats import bernoulli # Define the probability of success (getting a head for example) probability = 0.3 # Generate Bermoulli process random_samples = bernoulli.rvs(size=10, p=probability) print(f'Bernoulli process: {random_samples}')
copy

In .rvs() method above we specify size and p parameters. The first parameter is used to specify the number of values to generate and the second is used to specify the probability of success.

The binomial distribution is a discrete probability distribution that describes the number of successes (k) in a Bernoulli process with a fixed number of trials (n).

Let's look at the example:

12345678910
from scipy.stats import binom # Parameters n_samples = 10 # Number of trials proba = 0.5 # Probability of success # Calculate the probability that there are k successes k = 3 # Number of successes pmf = binom.pmf(k, n=n_samples, p=proba) print(f'Probability of getting {k} successes: {pmf:.4f}')
copy

We used .pmf() method of the scipy.stats.binom class with parameters n (number of trials) and p(probability of success) to calculate the probability that we have exactly 3 (the first argument of .pmf() method) successes in 10 Bernoulli trials. We will consider .pmf() method in more detail in Probability Theory Mastering course.

Note

It is important to understand the difference - the Bernoulli trial is a stochastic experiment with certain properties, while the binomial distribution is the rule by which we can calculate the probabilities of occurring events in the Bernoulli process.

Choose examples of Bernoulli trial:

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 1
We're sorry to hear that something went wrong. What happened?
some-alt