Bird
0
0

You want to calculate the cumulative probability for values in a dataset assuming a normal distribution with mean 0 and variance 0.5. Which code correctly uses erf to compute this?

hard📝 Application Q8 of 15
SciPy - Constants and Special Functions
You want to calculate the cumulative probability for values in a dataset assuming a normal distribution with mean 0 and variance 0.5. Which code correctly uses erf to compute this?
Afrom scipy.special import erf import numpy as np data = np.array([0, 0.5, 1]) cdf = erf(data * 0.5)
Bfrom scipy.special import erf import numpy as np data = np.array([0, 0.5, 1]) cdf = 0.5 * (1 + erf(data / np.sqrt(2 * 0.5)))
Cfrom scipy.special import erf import numpy as np data = np.array([0, 0.5, 1]) cdf = 1 - erf(data)
Dfrom scipy.special import erf import numpy as np data = np.array([0, 0.5, 1]) cdf = erf(data / 2)
Step-by-Step Solution
Solution:
  1. Step 1: Recall normal CDF formula using erf

    The CDF for normal distribution is 0.5 * (1 + erf(x / (sqrt(2) * sigma))).
  2. Step 2: Apply variance to standard deviation

    Standard deviation sigma = sqrt(variance) = sqrt(0.5).
  3. Step 3: Check code correctness

    from scipy.special import erf import numpy as np data = np.array([0, 0.5, 1]) cdf = 0.5 * (1 + erf(data / np.sqrt(2 * 0.5))) correctly divides data by sqrt(2 * 0.5) and applies formula.
  4. Final Answer:

    from scipy.special import erf\nimport numpy as np\ndata = np.array([0, 0.5, 1])\ncdf = 0.5 * (1 + erf(data / np.sqrt(2 * 0.5))) -> Option B
  5. Quick Check:

    Normal CDF formula with erf applied correctly [OK]
Quick Trick: Normal CDF = 0.5*(1+erf(x/(sqrt(2)*sigma))) [OK]
Common Mistakes:
MISTAKES
  • Ignoring variance in denominator
  • Using erf without scaling input

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes