Example 2

Time to First Fill — Statistical Analysis

Analyze patient prescription fill times, identify outliers using Z-scores, and simulate how sample size and outlier severity affect your statistics.

Simulation ModeDrag sliders to update stats in real-time
1,000
505,000
45 days
20 days120 days

Dataset Summary — Days to First Fill (n = 1,000)

Min: 5·Max: 45 (outlier)·Range: 40 days·n: 1,000

Mean

15.91days

Dragged upward by outliers

Median

16days

Better reflects typical patient

Std Dev

4.72days

High spread = inconsistent

Patients

1,000

Outlier at 45 days

Patient Data Distribution

P11P45P82P121P161P206P251P298P345P391P438P485P531P576P621P667P712P756P801P848P895P941P1000015304560DaysMean: 15.91Median: 16
Mean
Median
Outlier
Mean = 15.91 days — dragged upward by the 45-day outlier. Not representative of the typical patient.
Median = 16 days — better reflects the typical patient experience since it's resistant to outliers.
SD = 4.72 days — high spread indicates very inconsistent performance across patients.
Standard Deviation (SD)

Standard Deviation — Step-by-Step Calculation

Standard deviation measures the average distance between each patient's fill time and the dataset mean. You must calculate SD before you can compute a Z-score.

Standard Deviation Formula

1.SD = √[ Σ(Xᵢ − X̄)² / n ]
2.Σ(Xᵢ − 15.91)² = 22,244.72
3.Variance (σ²) = 22,244.72 / 1,000 = 22.24
4.SD = √22.24 = 4.72 days
ResultSD = 4.72 days
1

Calculate the Mean (X̄)

X̄ = ΣXᵢ / n = 15.91 days (n = 1,000)
2

Find each point's deviation & square it (Xᵢ − X̄)²

Outlier example: (45 − 15.91)² = 846.23
3

Sum all squared deviations Σ(Xᵢ − X̄)²

Σ(Xᵢ − X̄)² = 22,244.72
4

Divide by n to get Variance (σ²)

σ² = 22,244.72 / 1,000 = 22.24
5

Take the square root to get Standard Deviation (SD)

SD = √22.24 = 4.72 days
Z-Score

Outlier Detection — Patient at 45 Days

A Z-score tells us how many standard deviations a data point is from the mean. We use it to flag statistically significant outliers.

Z-Score Formula

1.Z = (X − X̄) / SD
2.Z = (45 − 15.91) / 4.72
3.Z = 29.09 / 4.72
4.Z = 6.16
ResultZ = 6.16
1

Identify the data point (X)

X = 45 days
2

Subtract the mean (X̄)

45 − 15.91 = 29.09
3

Divide by standard deviation

29.09 / 4.72 = 6.16
4

Compare to threshold |Z| > 1.96

|6.16| = 6.16 > 1.96 ✓

Z-Score Position on Normal Distribution

-1.96
+1.96
0
Z=6.16
-4σ-2σMean (0)+2σ+4σ
Normal range (|Z| ≤ 1.96)
Outlier zone (|Z| > 1.96)
A Z-score of 6.16 means this patient is 6.16 standard deviations above the mean.
Since |Z| > 1.96, this is a statistically significant outlier and should trigger a case review.
Automated escalation rule: Any patient crossing Z > 1.96 gets flagged for review — this is how you build alert systems in pharmacy operations.