Bird
0
0

You want to simulate the number of heads in 100 coin tosses repeated 50 times using scipy.stats. Which code snippet correctly generates this data?

hard📝 Application Q8 of 15
SciPy - Statistical Functions (scipy.stats) Basics
You want to simulate the number of heads in 100 coin tosses repeated 50 times using scipy.stats. Which code snippet correctly generates this data?
Afrom scipy.stats import uniform results = uniform.rvs(loc=0, scale=100, size=50)
Bfrom scipy.stats import norm results = norm.rvs(loc=50, scale=25, size=50)
Cfrom scipy.stats import binom results = binom.rvs(n=100, p=0.5, size=50)
Dfrom scipy.stats import poisson results = poisson.rvs(mu=50, size=100)
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct distribution for coin tosses

    Number of heads in fixed tosses follows a binomial distribution with n=100 and p=0.5.
  2. Step 2: Check code correctness

    from scipy.stats import binom results = binom.rvs(n=100, p=0.5, size=50) uses binom.rvs with correct parameters and size=50 for repetitions.
  3. Step 3: Verify other options

    Options B, C, D use wrong distributions or parameters for this problem.
  4. Final Answer:

    from scipy.stats import binom results = binom.rvs(n=100, p=0.5, size=50) -> Option C
  5. Quick Check:

    Binomial for coin toss counts, size=number of repeats [OK]
Quick Trick: Use binom.rvs for fixed trials with success probability [OK]
Common Mistakes:
MISTAKES
  • Using normal or uniform instead of binomial
  • Mixing size and n parameters
  • Incorrect mu for poisson

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes