Challenge - 5 Problems
Binomial Distribution Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Binomial PMF Calculation
What is the output of this code that calculates the probability of exactly 3 successes in 10 trials with success probability 0.5 using scipy's binom.pmf?
SciPy
from scipy.stats import binom result = binom.pmf(3, 10, 0.5) print(round(result, 4))
Attempts:
2 left
💡 Hint
Recall that binom.pmf(k, n, p) gives the probability of k successes in n trials with success probability p.
✗ Incorrect
The binomial PMF for k=3, n=10, p=0.5 is approximately 0.1172. This is calculated using the formula for binomial probability mass function.
❓ data_output
intermediate2:00remaining
Number of Trials with Probability Above Threshold
Using scipy's binom.pmf, how many values of k (from 0 to 10) have a probability greater than 0.1 for n=10 and p=0.3?
SciPy
from scipy.stats import binom probabilities = binom.pmf(range(11), 10, 0.3) count = sum(p > 0.1 for p in probabilities) print(count)
Attempts:
2 left
💡 Hint
Calculate probabilities for k=0 to 10 and count how many exceed 0.1.
✗ Incorrect
For n=10 and p=0.3, the PMF values above 0.1 occur for k=2,3,4,5,6, totaling 5 values.
❓ visualization
advanced3:00remaining
Identify the Correct Binomial PMF Plot
Which option shows the correct plot of the binomial PMF for n=5 and p=0.6?
SciPy
import matplotlib.pyplot as plt from scipy.stats import binom import numpy as np k = np.arange(0, 6) pmf = binom.pmf(k, 5, 0.6) plt.bar(k, pmf) plt.xlabel('Number of successes') plt.ylabel('Probability') plt.title('Binomial PMF for n=5, p=0.6') plt.show()
Attempts:
2 left
💡 Hint
Binomial PMF bars should sum to 1 and peak near np (here 5*0.6=3).
✗ Incorrect
The binomial PMF for n=5, p=0.6 peaks at k=3 and the bars sum to 1. The correct plot is a bar chart with these properties.
🧠 Conceptual
advanced2:00remaining
Effect of Increasing Number of Trials on Binomial Distribution Shape
What happens to the shape of the binomial distribution when the number of trials n increases while keeping the success probability p fixed?
Attempts:
2 left
💡 Hint
Think about the Central Limit Theorem and how binomial behaves for large n.
✗ Incorrect
As n increases, the binomial distribution approaches a normal distribution shape, becoming more symmetric around the mean np.
🔧 Debug
expert2:00remaining
Identify the Error in Binomial PMF Calculation Code
What error does this code produce when trying to calculate the binomial PMF for k=3, n=10, p=0.5?
from scipy.stats import binom
result = binom.pmf(3, 0.5, 10)
print(result)
SciPy
from scipy.stats import binom result = binom.pmf(3, 0.5, 10) print(result)
Attempts:
2 left
💡 Hint
Check the order of parameters for binom.pmf(k, n, p).
✗ Incorrect
The parameters are in wrong order: n should be second and p third. Passing p as n causes a TypeError.