How long does a ticket take?
You join an IT support desk. Your team leader asks: "How long do we take to close a ticket?"
Most tickets close in about a quarter of an hour. One ticket stayed open all weekend.
One number has to describe all of them. Which number you choose changes the answer a lot.
By the end of this lesson
Note
I can work out the mean, the median and the range of a list of numbers.
Key words
| Word | What it means | Example |
|---|---|---|
| Mean | the total divided by how many values | |
| Median | the middle value once they are in order | |
| Range | the biggest value take away the smallest | |
| Outlier | a value far from the others | 300 minutes |
| Summary statistic | one number that describes many |
The cells students fill in are left blank in this preview.
Worked example: the mean
| Step | What you do | Result |
|---|---|---|
| 1 | Write the times | 12, 15, 9, 20, 14 |
| 2 | Add them up | 70 |
| 3 | Count them | 5 |
| 4 | Divide the total by the count | 70 ÷ 5 = 14 minutes |
The cells students fill in are left blank in this preview.
Work out the mean in Python
# Minutes to close each support ticket this morning.
times = [12, 15, 9, 20, 14]
total = 0
for minutes in times:
total = total + minutes
mean = total / len(times)
print("Total:", total)
print("Mean:", mean)
# Add a ticket of 300 minutes to the list. What happens to the mean?
A common mistake
Warning
Many people think the mean is always the typical value. It is only typical when there are no outliers. One ticket of 300 minutes lifts the mean from 14 to over 60. No ticket took that long.
The median is the middle value
To find the median, put the values in order and take the one in the middle.
With an even count there are two middle values. The median is halfway between them.
One huge value only moves the median one place. So the median is a fairer summary when there are outliers.
Worked example: median and range
| Step | Five tickets | Six tickets, one outlier |
|---|---|---|
| Times | 12, 15, 9, 20, 14 | 12, 15, 9, 20, 14, 300 |
| In order | 9, 12, 14, 15, 20 | 9, 12, 14, 15, 20, 300 |
| Middle | 14 | 14 and 15 |
| Median | 14 | 14.5 |
| Range | 20 − 9 = 11 | 300 − 9 = 291 |
The cells students fill in are left blank in this preview.
Median and range in Python
times = [12, 15, 9, 20, 14, 300]
ordered = sorted(times)
print("In order:", ordered)
middle = len(ordered) // 2
if len(ordered) % 2 == 1:
median = ordered[middle]
else:
# An even count has two middle values: take halfway between them.
median = (ordered[middle - 1] + ordered[middle]) / 2
print("Median:", median)
spread = ordered[-1] - ordered[0]
print("Range:", spread)
# Take 300 out of the list, then press Run again.