aNet.ai
Data Science/Lab work
0day streak0XP · Lv 1
← Lab 2 overview and setup
Lab 2 · Section 3 of 8

Quartiles and a changed maximum

3A–3D

First · connect to the lecture

The lecture's robust summaries are tested by changing one extreme value. The lab also makes the quartile convention explicit.

Week 2: quartiles, range and sensitivity, PDF pp. 10–30

Your task

Use median-of-halves for the eight scores, predict the effect of multiplying the maximum by ten, then compare with the output.

Evidence to include

Report the five-number summary and IQR, two numerical changes, and why the hand/software quartiles may differ.

Notebook questions and code

Read here; run in your downloaded notebook. Start with its setup cells and run in order. Use your own ID and outputs where requested.

Download Lab 2 notebook

3 · Middle half, extremes, and sensitivity (15 min)

For the eight scores, use median of halves: Q1 is the median of the lower four; Q3 the median of the upper four. For the larger dataset later, use pandas linear interpolation. Different stated conventions can legitimately give different quartiles.

Before running, compute the five-number summary and IQR of your eight scores. Then predict what happens if the largest score is accidentally multiplied by 10.

Your reasoning

3A. Give min, Q1, median, Q3, max, and IQR by hand. Interpret the middle-half interval in a sentence.

3B. Prediction: which will change most after the error: mean or median? Will range, SD, and IQR change? Explain using which observations each measure depends on.

Answer: Replace this text with your explanation.

Python · cell 13 — read here, run in your notebook
def half_summary(a):
    a = np.sort(a)
    q1, q3 = np.median(a[:4]), np.median(a[4:])
    return pd.Series({'min':a.min(),'Q1':q1,'median':np.median(a),'Q3':q3,
        'max':a.max(),'mean':a.mean(),'range':np.ptp(a),'IQR':q3-q1,
        'sample variance':np.var(a,ddof=1),'sample SD':np.std(a,ddof=1)})
changed = small.copy(); changed[-1] *= 10
print('Changed scores:',changed.tolist())
display(pd.DataFrame({'original':half_summary(small),'with error':half_summary(changed)}))
print('Original pandas linear quartiles:',pd.Series(small).quantile([.25,.75]).to_dict())

Your reasoning

3C. Compare predictions with results, citing at least two numerical changes. Why can the median and IQR stay stable here? Does that make them universally best?

3D. Explain any difference between hand and software quartiles. Why is the altered score impossible in this context, whereas a very large number of platform minutes may be valid?

Answer: Replace this text with your explanation.

Saved only in this browser. This note doesn’t fill in the downloaded notebook; “reviewed” is a personal checklist, not a grade.

aNet.ai · Data Science Fundamentals · Weeks 1–5 · practice material, not an official examProgress saved in this browser