Complete the code to import the binomial distribution function from scipy.stats.
from scipy.stats import [1]
The binom function in scipy.stats is used to work with the binomial distribution.
Complete the code to calculate the probability mass function (PMF) for 3 successes in 10 trials with success probability 0.5.
prob = binom.pmf([1], 10, 0.5)
The PMF calculates the probability of exactly k successes. Here, k=3.
Fix the error in the code to calculate the cumulative distribution function (CDF) for 4 successes in 8 trials with probability 0.3.
cdf_value = binom.[1](4, 8, 0.3)
pmf or pdf instead of cdf.sf which is complementary.The CDF function is cdf, which gives the probability of up to 4 successes.
Fill both blanks to create a dictionary of probabilities for successes greater than 2 in 5 trials with probability 0.4.
prob_dict = {k: binom.[1](k, 5, 0.4) for k in range(3, [2])}We use pmf to get exact probabilities and range(3, 6) to include successes 3, 4, and 5.
Fill all three blanks to create a dictionary of probabilities for successes less than 4 in 7 trials with probability 0.6.
probabilities = {k: binom.[1](k, [2], [3]) for k in range(4)}We use pmf for exact probabilities, 7 trials, and 0.6 success probability.