Z-scores and the reference group
7A–7E
The same raw score gets different z-scores when the reference changes. This lab uses sample SD (ddof=1); the Week 4 prediction scaler uses training-only population-style SD (ddof=0).
Week 2: z-score, rank and specification, PDF pp. 45–50; Week 4 scaling is a later connection
Your task
Predict whether z changes, show a calculation, explain the standardised column, compare distance with percentile rank, and apply the bottle specification.
Evidence to include
Name the reference group and SD convention. Use your table, the extreme practice-time value, and the stated 94–106 mL acceptance interval.
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 notebook7 · Relative to whom? (15 min)
A z-score is (value − reference mean) / reference SD. It is unitless; the reference SD must be positive. Positive means above the mean, not automatically good. Computing z does not require normality; converting it into a normal-model rarity does.
Prediction: the selected student's raw score will stay fixed while the reference group changes. Must their z-score remain fixed? Explain before running.
Your reasoning
7A. Prediction: explain which ingredients can change and why.
Answer: Replace this text with your explanation.
Python · cell 29 — read here, run in your notebook
focus=students.iloc[focus_index]
print('Selected record:',int(focus.record_id),'| programme:',focus.programme,'| entry score:',focus.entry_score)
rows=[]
for label,ref in [('Whole cohort',students.entry_score),
('Programme A',students.loc[students.programme=='A','entry_score']),
('Programme B',students.loc[students.programme=='B','entry_score'])]:
sd=ref.std(ddof=1)
rows.append({'reference':label,'n':len(ref),'mean':ref.mean(),'sample SD':sd,
'z':(focus.entry_score-ref.mean())/sd if sd>0 else np.nan})
display(pd.DataFrame(rows))
students['entry_z_cohort']=(students.entry_score-students.entry_score.mean())/students.entry_score.std(ddof=1)
print('Standardised column mean / sample SD:',students.entry_z_cohort.mean(),students.entry_z_cohort.std(ddof=1))
# A separate personalised example separates distance from rank.
rank_times = np.r_[np.arange(1,10),int(46 + seed % 21)].astype(float)
target=9.
print('Practice minutes:',rank_times.tolist())
print('Target:',target,'| z:',(target-rank_times.mean())/rank_times.std(ddof=1),
'| percentile rank (at or below):',100*np.mean(rank_times<=target))Your reasoning
7B. Show one z-score calculation from the table. Write its interpretation with the reference group and direction. Which reference answers “unusual within this student's own programme”?
7C. Explain the mean and SD of the standardised column. Would standardising programme codes be meaningful? What if all values in a reference group were identical?
7D. In the practice-time example, how can 9 minutes be below the mean yet at the 90th percentile? Use the extreme observation in your explanation. Why should you not automatically interpret z=2 as a particular percentile?
7E. A bottle process has reference mean 100 mL and SD 2 mL. Its explicitly agreed specification is 94–106 mL inclusive. For bottles of 104 and 108 mL, calculate z and decide acceptance. Explain why rejecting a bottle does not mean deleting its measurement, and why z alone does not set the acceptance rule.
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.