Bird
0
0

You have a dataset of exam scores: [55, 70, 65, 80, 90, 85, 75]. You want to divide the scores into four equal groups (quartiles) using scipy. Which code snippet correctly computes the quartiles?

hard📝 Application Q15 of 15
SciPy - Statistical Functions (scipy.stats) Basics
You have a dataset of exam scores: [55, 70, 65, 80, 90, 85, 75]. You want to divide the scores into four equal groups (quartiles) using scipy. Which code snippet correctly computes the quartiles?
Astats.mstats.mquantiles(scores, prob=[0.25, 0.5, 0.75])
Bstats.scoreatpercentile(scores, [25, 50, 75])
Cnp.percentile(scores, [0.25, 0.5, 0.75])
Dstats.mstats.mquantiles(scores, prob=[25, 50, 75])
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct function for quartiles

    Quartiles are quantiles at 25%, 50%, and 75%. stats.mstats.mquantiles accepts prob as fractions between 0 and 1.
  2. Step 2: Check options for correct prob format

    stats.mstats.mquantiles(scores, prob=[0.25, 0.5, 0.75]) uses prob=[0.25, 0.5, 0.75], which is correct. stats.scoreatpercentile(scores, [25, 50, 75]) uses scoreatpercentile but with a list, which is invalid. np.percentile(scores, [0.25, 0.5, 0.75]) uses numpy but with fractions instead of percentages. stats.mstats.mquantiles(scores, prob=[25, 50, 75]) uses prob with values >1, which is invalid.
  3. Final Answer:

    stats.mstats.mquantiles(scores, prob=[0.25, 0.5, 0.75]) -> Option A
  4. Quick Check:

    mquantiles prob values are fractions [OK]
Quick Trick: Use mquantiles with prob as fractions (0.25, 0.5, 0.75) [OK]
Common Mistakes:
MISTAKES
  • Passing percent values instead of fractions to prob
  • Using scoreatpercentile with list of percentiles
  • Confusing numpy percentile input format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes