Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Probability Mass Function (PMF) 2/2 | Probability Functions
Probability Theory Update
course content

Conteúdo do Curso

Probability Theory Update

Probability Theory Update

1. Probability Basics
2. Statistical Dependence
3. Learn Crucial Terms
4. Probability Functions
5. Distributions

Probability Mass Function (PMF) 2/2

Probability mass function over a range:

In some cases, we want to know the probability that discrete random variables are equal to numbers over a range.

Example:

Calculate the probability that we will have success with the fair coin at 4 or less times (0, 1, 2, 3 or 4) (the chance of getting head or tail is 50%) if we have 15 attempts. We assume that success means getting a head.

Python realization:

12345678910111213141516171819202122232425262728293031
# Import required library import scipy.stats as stats # The probability of getting 0 successes prob_0 = stats.binom.pmf(0, n = 15, p = 0.5) # The probability of getting 1 success prob_1 = stats.binom.pmf(1, n = 15, p = 0.5) # The probability of getting 2 successes prob_2 = stats.binom.pmf(2, n = 15, p = 0.5) # The probability of getting 3 successes prob_3 = stats.binom.pmf(3, n = 15, p = 0.5) # The probability of getting 4 successes prob_4 = stats.binom.pmf(4, n = 15, p = 0.5) # The resulting probability probability = prob_0 + prob_1 + prob_2 + prob_3 + prob_4 print("The probability is", probability * 100, "%")
copy

Explanation

We've found the probability that a discrete random variable will equal exactly 0, 1, 2, 3, or 4 using the probability mass function. Then, we summed up all probabilities using the addition rule because each of the found outcomes was permissible for us.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 4. Capítulo 3
toggle bottom row

Probability Mass Function (PMF) 2/2

Probability mass function over a range:

In some cases, we want to know the probability that discrete random variables are equal to numbers over a range.

Example:

Calculate the probability that we will have success with the fair coin at 4 or less times (0, 1, 2, 3 or 4) (the chance of getting head or tail is 50%) if we have 15 attempts. We assume that success means getting a head.

Python realization:

12345678910111213141516171819202122232425262728293031
# Import required library import scipy.stats as stats # The probability of getting 0 successes prob_0 = stats.binom.pmf(0, n = 15, p = 0.5) # The probability of getting 1 success prob_1 = stats.binom.pmf(1, n = 15, p = 0.5) # The probability of getting 2 successes prob_2 = stats.binom.pmf(2, n = 15, p = 0.5) # The probability of getting 3 successes prob_3 = stats.binom.pmf(3, n = 15, p = 0.5) # The probability of getting 4 successes prob_4 = stats.binom.pmf(4, n = 15, p = 0.5) # The resulting probability probability = prob_0 + prob_1 + prob_2 + prob_3 + prob_4 print("The probability is", probability * 100, "%")
copy

Explanation

We've found the probability that a discrete random variable will equal exactly 0, 1, 2, 3, or 4 using the probability mass function. Then, we summed up all probabilities using the addition rule because each of the found outcomes was permissible for us.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 4. Capítulo 3
toggle bottom row

Probability Mass Function (PMF) 2/2

Probability mass function over a range:

In some cases, we want to know the probability that discrete random variables are equal to numbers over a range.

Example:

Calculate the probability that we will have success with the fair coin at 4 or less times (0, 1, 2, 3 or 4) (the chance of getting head or tail is 50%) if we have 15 attempts. We assume that success means getting a head.

Python realization:

12345678910111213141516171819202122232425262728293031
# Import required library import scipy.stats as stats # The probability of getting 0 successes prob_0 = stats.binom.pmf(0, n = 15, p = 0.5) # The probability of getting 1 success prob_1 = stats.binom.pmf(1, n = 15, p = 0.5) # The probability of getting 2 successes prob_2 = stats.binom.pmf(2, n = 15, p = 0.5) # The probability of getting 3 successes prob_3 = stats.binom.pmf(3, n = 15, p = 0.5) # The probability of getting 4 successes prob_4 = stats.binom.pmf(4, n = 15, p = 0.5) # The resulting probability probability = prob_0 + prob_1 + prob_2 + prob_3 + prob_4 print("The probability is", probability * 100, "%")
copy

Explanation

We've found the probability that a discrete random variable will equal exactly 0, 1, 2, 3, or 4 using the probability mass function. Then, we summed up all probabilities using the addition rule because each of the found outcomes was permissible for us.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Probability mass function over a range:

In some cases, we want to know the probability that discrete random variables are equal to numbers over a range.

Example:

Calculate the probability that we will have success with the fair coin at 4 or less times (0, 1, 2, 3 or 4) (the chance of getting head or tail is 50%) if we have 15 attempts. We assume that success means getting a head.

Python realization:

12345678910111213141516171819202122232425262728293031
# Import required library import scipy.stats as stats # The probability of getting 0 successes prob_0 = stats.binom.pmf(0, n = 15, p = 0.5) # The probability of getting 1 success prob_1 = stats.binom.pmf(1, n = 15, p = 0.5) # The probability of getting 2 successes prob_2 = stats.binom.pmf(2, n = 15, p = 0.5) # The probability of getting 3 successes prob_3 = stats.binom.pmf(3, n = 15, p = 0.5) # The probability of getting 4 successes prob_4 = stats.binom.pmf(4, n = 15, p = 0.5) # The resulting probability probability = prob_0 + prob_1 + prob_2 + prob_3 + prob_4 print("The probability is", probability * 100, "%")
copy

Explanation

We've found the probability that a discrete random variable will equal exactly 0, 1, 2, 3, or 4 using the probability mass function. Then, we summed up all probabilities using the addition rule because each of the found outcomes was permissible for us.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 4. Capítulo 3
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt