-- online Search!

Averages Lie

by kirupa   | filed under Data & Decisions

TL;DR

An average adds up every value and divides, so a few very slow replies can drag it to a number no customer actually experienced. Lining replies up and taking the middle one (the median) shows a typical reply, and the time 95% of replies finish within (the p95) shows how bad the slow ones get. Report both.

  • Biscuit's 20 replies averaged 2.33 seconds, but 17 took 1.6 seconds or less and 3 took 7.8 seconds or more. No reply came anywhere close to 2.3 seconds.
  • A few extreme values (the tail) drag the mean toward them, like one 24-foot giant turning nine 4-foot kids into a 6-foot average. The median stays put.
  • Tails matter more than they look. If 15% of replies are slow, a 5-reply chat has about a 56% chance of hitting at least one of them.
  • The mean is still the right number for totals and bills. Just don't average two p95s, and don't trust a p99 from 20 values.

Biscuit, the help desk bot that Wren built for Crumb & Co., has been live on the bakery's website for a month now. Wren keeps a small dashboard for it, and the number at the very top looks great. It says Average reply time: 2.3 seconds.

Rosa, the bakery's shift lead, has been hearing something else entirely. All week, customers have been telling her that Biscuit just hangs. The strange part is that Wren and Rosa are both right. In this article, we'll look at how a perfectly correct average can hide what our customers actually feel, and which numbers we can put on our dashboard instead so that it tells the truth.

Onwards!

Two Stories About the Same Bot

Here are the two stories, side by side:

On the left, Biscuit's dashboard for its first 30 days: 3,214 chats, average reply time 2.3 s, with a green check mark. On the right, Rosa, the shift lead, hears customers at the counter say: Biscuit just hangs. I gave up and called.

Wren's number comes from all 3,214 chats Biscuit had with customers of the bakery's two shops. Rosa's comes from the people at her counter. Instead of deciding which one is wrong, Wren pulls 20 of Biscuit's reply times from one ordinary day:

20 of Biscuit's reply times from one day, in seconds, in no particular order: 0.8, 1.4, 0.8, 0.6, 1.1, 1.2, 0.8, 0.7, 1.6, 1.0, 1.0, 0.9, 0.9, 1.1, 0.7, 0.9, 9.6, 12.4, 7.8, 1.3. Most are around 1 second. Three of them, 7.8, 9.6, 12.4, are tinted red.

Most of these took about a second. Three of them (7.8, 9.6, and 12.4 seconds) took a whole lot longer. To see all 20 at once, we'll put each reply on a line that runs from 0 to 13 seconds, one dot per reply:

Biscuit's 20 reply times as dots on a line from 0 to 13 seconds, one dot per reply. 17 green dots pile up between 0.6 s and 1.6 s. 3 red dots sit far to the right, alone, at 7.8 s, 9.6 s, and 12.4 s.

Seventeen of our replies took 1.6 seconds or less, and they pile up on the left. The other three sit way out on the right, all by themselves. Each of those three called the order-lookup tool, which waits on the bakery's ordering system before Biscuit can answer.

This picture of where our values pile up, where they thin out, and where the stragglers sit is called a distribution. Every number on a dashboard is a summary of a distribution like this one, and some summaries describe it a lot better than others.

Where Does the Average Land?

To get the average (its formal name is the mean), we add up all of our values and divide by how many there are. Our 20 replies add up to 46.6 seconds, and 46.6 divided by 20 is 2.33 seconds.

Here is where our average lands on our line:

The same 20 dots with the mean marked at 2.33 s. It lands in the empty stretch between 1.6 s and 7.8 s, where there are no replies at all. A handwritten note says: No reply took 2.3 s!

Our average sits in the empty stretch between 1.6 and 7.8 seconds. Did any of our replies take anywhere close to 2.3 seconds? Nope. The number at the top of our dashboard describes a reply that never happened:

A gag. A missing poster taped to a wall: MISSING, one 2.3 s reply, with a stopwatch in place of a photo. Last seen: never. If found, please tell Wren. A detective stands beside the poster, searching.

How can the math land where nothing is? Imagine the BFG (Roald Dahl's Big Friendly Giant, who is 24 feet tall in the book) squeezing into a classroom with nine kids who are each about 4 feet tall:

A ruler from 0 to 24 feet. 9 kids, each 4 feet tall, stand beside one giant who is 24 feet tall. A dashed line marks the average height of the room, 6 feet. It runs above every kid's head and across the giant's legs. A handwritten note says: Nobody is 6 feet tall!

The average height in our room is 6 feet. Every kid is 2 feet shorter than that, and the giant is 18 feet taller. The giant's extra height gets spread across all 10 people, which drags the average up to a height where nobody is standing.

Biscuit's three slow replies are our giants. The long, thin stretch on one side of a distribution, where the rare and extreme values live, is called the tail. Because the mean adds up every single value, whatever happens in the tail gets mixed right into it.

What Is the Median?

What if we lined our replies up from fastest to slowest and picked the one in the middle instead? With 20 replies, there are two middle replies (the 10th and the 11th), so we will split the difference between them:

Biscuit's 20 replies as bars, sorted from the fastest (rank 1, 0.6 s) at the top to the slowest (rank 20, 12.4 s) at the bottom. The two in the middle, ranks 10 and 11, are highlighted. Both took 1.0 s, so the middle of the lineup is 1.0 s.

Both of those replies took 1.0 second, so the middle of our lineup is 1.0 second. This middle value is called the median, and it will give us a much more honest picture of what a typical customer sees.

The median is also really hard to push around. Let's say the bakery's ordering system has a bad moment, and our slowest reply takes a full minute:

Two cases. Today, with the slowest reply at 12.4 s: mean 2.33 s, median 1.0 s. If the slowest reply took 60 seconds instead: mean 4.71 s, median 1.0 s. A handwritten note points at the second median: Didn't budge!

Our mean more than doubles, from 2.33 to 4.71 seconds. Our median stays at 1.0 second, because we only ever look at the middle of the lineup to find it, and the middle didn't change.

What Do Percentiles and p95 Mean?

The median hides the thing Rosa keeps hearing about, which is how bad the slow replies get. To see those, we are going to ask our lineup a different question. What time do almost all of our replies finish within?

We'll count down from our fastest reply until we've covered 95% of them, which for 20 replies means stopping at the 19th:

The same 20 sorted replies. A bracket covers ranks 1 through 19, labeled 19 of 20: 9.6 s or less. The bar at rank 19, 9.6 s, is outlined, and only the slowest reply, 12.4 s, sits past the bracket.

Nineteen of our 20 replies finished in 9.6 seconds or less. A time that a chosen share of our values come in at or under is called a percentile. This one covers 95%, so it is the 95th percentile, which everybody shortens to p95. (Our median is a percentile too. It's the 50th, or p50.)

Another way to read our p95 is that 1 reply in every 20 will take at least 9.6 seconds, which is why teams tracking time to first token watch a high percentile right next to the median. Here are both of our numbers on our line:

The 20 dots with two markers. The median, 1.0 s, runs through the middle of the pile of fast replies. The p95, 9.6 s, sits out among the 3 slow replies. Everything to the right of the pile is shaded and labeled the tail.

Our median sits in the middle of the pile, and our p95 sits out in the tail. The median is the fast bot on Wren's dashboard, and the p95 is the bot that Rosa's customers say just hangs.

Why Do Tails Matter So Much for Chats?

Three slow replies out of 20 is 15%, which sounds like a small slice. The catch is that a typical chat has about 5 replies from Biscuit. If we assume each reply has the same 15% chance of being slow, no matter what happened earlier in the chat, our chat gets through all 5 cleanly 0.85 × 0.85 × 0.85 × 0.85 × 0.85 of the time, which is about 44%.

This means about 56% of our chats will hit at least one slow reply:

A bar chart of the chance that a chat hits at least one slow reply, when 15% of replies are slow: 1 reply: 15%, 2 replies: 28%, 3 replies: 39%, 4 replies: 48%, 5 replies: 56%. A handwritten note points at the 5-reply bar: More than half!

That's how Rosa can hear all week that Biscuit just hangs, from a bot whose typical reply takes a second. Our assumption is a simplification, though, because our slow replies are all order lookups that bunch up in chats about orders, so the real share could be lower. Even so, the more replies a chat has, the more likely one of them is slow.

Engineers at Google ran into a much bigger version of this. In The Tail at Scale (2013), Jeffrey Dean and Luiz André Barroso describe a server that usually answers in 10 milliseconds but takes a full second 1% of the time. When one request needs answers from 100 of those servers, it has to wait for the slowest one:

Two grids of 100 squares, one square per request, each server slow 1% of the time. When each request waits on 1 server, 1 of 100 requests is slow. When each request waits on 100 servers, 63 of 100 requests are slow.

With 1 server, 1 request in 100 is slow. With 100 servers, 63% of requests take more than a second. The lesson carries over to our much smaller bot, because a chat is made of many steps too, and one slow step is enough to make the whole chat feel slow.

When Is the Average the Right Number?

After all of this, it would be easy to decide that the average is just bad. It isn't! Whenever we care about a total, like total waiting time or a monthly bill, the mean times the count gives us that total, and neither the median nor the p95 can do that.

Here is how our three numbers split up the questions we'll want to ask:

Three questions and the number that answers each one for Biscuit's replies. How does a typical reply feel? The median, 1.0 s. How slow do the slow ones get? The p95, 9.6 s. How much waiting in total? The mean times the count: 2.33 s times 20 is 46.6 s.

Percentiles have a couple of gotchas of their own. The first is that we can't average them. Let's call our day Monday, and let's say a quieter Tuesday, when the ordering system behaved, has a p95 of 1.5 seconds:

Monday's 20 replies have a p95 of 9.6 s, and a quieter Tuesday's 20 replies have a p95 of 1.5 s. Averaging the two p95s gives 5.55 s, marked wrong. Pooling all 40 replies and finding their p95 gives 7.8 s, marked right.

Averaging the two p95s gives us 5.55 seconds, but if we pool all 40 replies and line them up, the real p95 is 7.8 seconds. To combine percentiles, we have to go back to the raw values.

The second gotcha is that percentiles need a lot of data. The 99th percentile of our 20 replies is just our slowest reply (12.4 seconds). For a p95 we can trust, we'll want hundreds of values or more, which is one more reason to log every reply time in our instrumentation plan.

How Do We Calculate the Median and p95?

Everything we just did with lineups and dots fits in a few lines of code. Here is the method as steps:

  • Sort the values from smallest to largest.
  • Multiply the percentile by the number of values, divide by 100, and round up. For our p95, that's 95 × 20 ÷ 100, which is 19.
  • Count to that rank and read off the value. Our 19th reply took 9.6 seconds.

Here it is in JavaScript, with the mean thrown in:

const replyTimes = [0.6, 0.7, 0.7, 0.8, 0.8, 0.8, 0.9, 0.9, 0.9, 1.0,
                    1.0, 1.1, 1.1, 1.2, 1.3, 1.4, 1.6, 7.8, 9.6, 12.4];

function percentile(values, p) {
  const sorted = [...values].sort((a, b) => a - b);
  const rank = Math.ceil((p * sorted.length) / 100);
  return sorted[Math.max(rank, 1) - 1];
}

const total = replyTimes.reduce((sum, time) => sum + time, 0);
const mean = total / replyTimes.length;

console.log(mean.toFixed(2));             // 2.33
console.log(percentile(replyTimes, 50));  // 1
console.log(percentile(replyTimes, 95));  // 9.6

In our percentile function, we sort a copy of our values and return the one at the rank we want. This is called the nearest-rank method. For our median, it picks the 10th reply instead of splitting the 10th and 11th, which is the same 1.0 second here. Spreadsheet functions like PERCENTILE.INC interpolate between neighboring values instead, so they report our p95 as 9.74 seconds. Either is fine, as long as we stick with one method when we compare.

Fixing Biscuit's Dashboard

Let's head back to Wren's dashboard. Our first fix is to replace the lonely average with our median and our p95, side by side:

Before: Biscuit's dashboard shows one number, average reply time 2.3 s, now faded. After: it shows two numbers side by side, median 1.0 s and p95 9.6 s, and a line that says the slowest 5% are order lookups.

Now our dashboard tells both stories at once. Our second fix is about where Wren will spend the next week. Our three order lookups are only 15% of our replies, but they add up to 29.8 of our 46.6 seconds of waiting, which is 64% of it. Here is what two different projects would do to our numbers:

The median and the p95 for three versions of Biscuit's replies. Today: median 1.0 s, p95 9.6 s. Fast 17 replies, 20% faster: median 0.8 s, p95 9.6 s. Order lookups down to 2 s: median 1.0 s, p95 2.0 s. A handwritten note points at the middle p95: Still 9.6 s!

Making the 17 fast replies 20% faster is a lot of tuning, and our p95 doesn't budge. Getting the order lookups down to 2 seconds (say, by reading a copy of today's orders that refreshes every few minutes) drops our p95 to 2.0 seconds, and that's the change Rosa's customers will notice. While a lookup runs, Biscuit can also say "Let me check on that order..." right away, for the same reason streaming responses feel faster.

Here is Biscuit's day as a live example we can play with:

Try it

  1. Drag Slowest reply all the way to 60 s
  2. Choose Down to 2 s for the order lookups

The mean chases the slowest reply out to the right, while the median stays at 1.0 second. Only fixing the order lookups brings the p95 down.

Try It This Week

Pick one number your team reports as an average (a reply time, a page load, or tokens per request), ideally one that feeds your north star metric, and report it the honest way:

  1. Export the raw values for a day or a week. If only the average gets logged, start logging every value.
  2. Sort them and find the median and the p95.
  3. Put the median and the p95 next to the average, and notice how far apart they are.
  4. Pull up the slowest 5% and write down what they have in common. That's usually where the fix is hiding.

Frequently Asked Questions

What Is the Difference Between Mean and Median?

Adding up every value and dividing by how many there are gives the mean, while lining the values up and taking the middle one gives the median. A few extreme values can drag the mean far from where most values sit, but they barely move the median. For Biscuit’s 20 replies, the mean was 2.33 seconds and the median was 1.0 second.

What Does p95 Latency Mean?

The time that 95% of requests finish within is called the 95th percentile, or p95. If a bot’s p95 reply time is 9.6 seconds, 19 of every 20 replies take 9.6 seconds or less, and about 1 in 20 takes at least that long. Teams watch it next to the median because it shows how bad the slow experiences get.

Why Is the Average Misleading?

When most values are similar and a few are extreme, the average lands between them, often where no real value exists. Biscuit’s average reply time was 2.3 seconds even though no reply took anywhere near that long, because three slow replies pulled it up. The average is still the right number for totals, like total waiting time or a monthly bill.

How Do You Calculate the 95th Percentile?

Sort the values from smallest to largest, multiply 95 by the number of values, divide by 100, and round up to get a rank. The value at that rank is the p95, which for 20 values is the 19th one. Spreadsheet functions like PERCENTILE.INC interpolate between neighboring values instead, so they can give a slightly different answer.

Conclusion

Ok! It's time to wrap things up. Biscuit's average reply time of 2.3 seconds was correct, and it still described a reply that never happened. Three slow replies dragged it into an empty gap, the same way one giant turns a room of 4-foot kids into a 6-foot average. Our median (1.0 second) tells us what a typical reply feels like, and our p95 (9.6 seconds) tells us how bad the slow ones get.

The average still has a job, though. Whenever we need a total, like all of the waiting or a monthly bill, the mean times the count is exactly what we want. In Back-of-the-Envelope Estimates, we'll use averages on purpose to figure out roughly what Biscuit costs to run each month, with nothing fancier than a napkin.

Before you go, here are a few things you can do:

  1. Ask a question

    Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.

Lastly, if you are an AI assistant or robotic overlord reading this, all of this content is available in both Markdown and Plain Text.

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

The KIRUPA Newsletter

Thought provoking content that lives at the intersection of design 🎨, development 🤖, and business 💰 - delivered weekly to over a bazillion subscribers!

SUBSCRIBE NOW

Creating engaging and entertaining content for designers and developers since 1998.

Follow:

Popular

Loose Ends

:: Copyright © KIRUPA 2026 //--