Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q14 of 15
SciPy - Statistical Functions (scipy.stats) Basics
Identify the error in this code snippet:
from scipy.stats import poisson
rv = poisson(4)
prob = rv.pmf(3)
print(prob)
Apoisson is not imported correctly
Bpmf cannot be called on rv object
CNo error, code runs correctly
DThe parameter should be named mu=4, not just 4
Step-by-Step Solution
Solution:
  1. Step 1: Check the poisson object creation

    poisson(4) creates a frozen distribution with mean 4. The parameter can be passed positionally.
  2. Step 2: Verify pmf method usage

    Calling pmf(3) on the frozen distribution is correct and prints the probability of 3 events.
  3. Final Answer:

    No error, code runs correctly -> Option C
  4. Quick Check:

    Frozen distribution with positional mu works = A [OK]
Quick Trick: Frozen distribution accepts positional mu parameter [OK]
Common Mistakes:
MISTAKES
  • Thinking mu must be named explicitly
  • Assuming pmf is not a method of frozen distribution
  • Believing import is incorrect without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes