Lesson 13 of 19 · Statistics for AI, GenAI & LLMs

Continuous Distributions: Density, the CDF, and the Shapes Beyond the Bell Curve

Latency, time between requests, and a model's true accuracy are not countable outcomes. They live on a smooth scale, and they need a different way to talk about probability.

Lesson 4 gave you distributions for outcomes you can list: a label, a token, a request count. Lesson 12 defined random variables, expectation, and variance. Much of what you monitor in an AI system does not come in steps: a response takes 412.7318… ms, the pause between two API calls is any positive number of seconds, a model's real accuracy is some number between 0 and 1. These are continuous random variables, and probability works differently for them. Then come four shapes you will meet constantly: uniform, exponential, gamma, and beta.

1. Why one exact value has probability zero

Suppose gaps between requests can be any positive real number. Ask: what is the probability that the next gap is exactly 0.5 seconds, not 0.5000001, not 0.4999999? Infinitely many values are packed into any interval, so the probability of landing on one specific value is 0. That is not impossible (some exact value occurs every time); each single value just carries no probability of its own. What does have probability is a range. To describe how probability is spread over the line, a continuous variable gets a probability density function (PDF), written f(t). Its rule is simple:

Key Insight Probability is area under the density curve, not the height of the curve. P(a ≤ X ≤ b) is the area between a and b. The total area under the whole curve is exactly 1.

Take gaps between requests that follow f(t) = 2e−2t for t ≥ 0 (the exponential shape from section 4). Look at the height at t = 0.5 and the probability of narrow windows starting there:

height at t = 0.5: f(0.5) = 2 × e^(-1) = 0.736
P(0.5 ≤ T ≤ 0.6) = e^(-1.0) - e^(-1.2) = 0.0667
P(0.5 ≤ T ≤ 0.51) = e^(-1.0) - e^(-1.02) = 0.00728
window width → 0 gives probability → 0

Each window is about 0.736 × its width: the height times a sliver of width, which is a sliver of area. Shrink the sliver to nothing and the area vanishes. The height 0.736 is a density, probability per second, not a probability.

0123012gap between requests t (seconds) height f(0.5) = 0.736 shaded area = P(0 ≤ T ≤ 0.5) = 0.632 density

The shaded area from 0 to 0.5 seconds is the probability of a gap that short: 1 − e−1 = 0.632. The dot marks a height, not a probability.

Pitfall A density can exceed 1. This curve starts at height 2, which would be a nonsense probability. Only the area must stay at or below 1. For the same reason, P(X < 0.5) and P(X ≤ 0.5) are identical for a continuous variable.

Lesson 12's expectation and variance keep their meaning here: the sum over outcomes becomes an integral. You will not integrate by hand; the formulas below are all you need.

2. The CDF, and reading percentiles off it

Areas are awkward to read from a density. The cumulative distribution function (CDF) does the accumulating for you: F(t) = P(X ≤ t), the area under the density up to t. It climbs from 0 to 1 and never goes down. For the gap distribution above, F(t) = 1 − e−2t:

t (seconds)F(t) = 1 − e−2tReads as
0.50.632163.2% are 0.5 s or shorter
1.50.950295.0% are 1.5 s or shorter

Two uses matter day to day. First, any range probability is a difference of two CDF values: P(a < X ≤ b) = F(b) − F(a). For gaps between 0.25 s and 0.75 s: F(0.75) − F(0.25) = 0.7769 − 0.3935 = 0.3834.

Second, running the CDF backwards gives a percentile. The 95th percentile (p95) is the value t where F(t) = 0.95. Set 1 − e−2t = 0.95, so e−2t = 0.05, so t = ln(20) / 2 = 1.498 s. The median (p50) solves F(t) = 0.5, giving t = ln(2) / 2 = 0.347 s.

012300.50.951gap between requests t (seconds) p50 = 0.347 s p95 = 1.498 s 95% of gaps are shorter F(t)

Read across from 0.95 on the vertical axis until you hit the curve, then straight down: 1.498 s. The same move from 0.5 gives the median.

This is exactly what a latency dashboard does when it reports p50 and p95: it reads the CDF backwards. Notice the median (0.347 s) sits well below the mean (0.5 s, derived in section 4). That is the right-skew from Lesson 2: a long tail of large values pulls the mean past the median.

Pitfall Percentiles do not average. If server A has p95 = 300 ms and server B has 500 ms, the combined p95 is not 400 ms. Pool the raw measurements and read the percentile from the pooled CDF.

3. Uniform: every value in a range equally likely

The simplest continuous shape is the uniform distribution on [a, b]: a flat density of height 1/(b − a) between a and b, and zero outside. Its CDF is a straight ramp, F(x) = (x − a)/(b − a). Mean and variance (Lesson 12's two summaries) come out as:

mean = (a + b) / 2
variance = (b - a)^2 / 12

Random weight initialization

Draw each starting weight from Uniform(−0.1, 0.1). Mean = (−0.1 + 0.1)/2 = 0. Variance = (0.2)²/12 = 0.04/12 = 0.00333, so the standard deviation is 0.0577. Half the weights land within ±0.05, since 0.1 of width out of 0.2 total is 0.5.

Random sampling threshold

To log 30% of requests for review, draw u from Uniform(0, 1) per request and log it when u < 0.3. The CDF of a Uniform(0, 1) is F(x) = x, so P(u < 0.3) = 0.3 exactly. Every request gets an independent draw.

4. Exponential: the time until the next event

In Lesson 4 the Poisson distribution counted requests per second when they arrive at an average rate λ. The exponential distribution describes the same traffic from the other side: not how many arrive in a second, but how long you wait between one arrival and the next. Same λ, one rate, two views.

density f(t) = λ e^(-λt) for t ≥ 0
CDF F(t) = 1 - e^(-λt)
mean = 1 / λ
variance = 1 / λ^2
λ = 2 requests per second:
mean gap = 1/2 = 0.5 s, variance = 1/4 = 0.25, sd = 0.5 s
P(gap > 1 s) = e^(-2) = 0.1353

That last number should look familiar. In Lesson 4 you saw that with λ = 2 the chance of zero requests in a given second is 0.135. It is the same event: "no request in a second" is the same as "the next gap is longer than a second."

The memoryless property

The exponential has an odd, useful property. If you have already waited and nothing has arrived, the remaining wait has the same distribution as a fresh wait. Say 0.5 seconds have passed with no request. What is the chance you wait more than 1 additional second?

P(T > 1.5 | T > 0.5) = P(T > 1.5) / P(T > 0.5)
= e^(-3) / e^(-1)
= e^(-2)
= 0.1353 (identical to P(T > 1))

The system is never "due": silence so far does not make the next request more likely. That is what independent arrivals from many users look like. It fits arrival gaps, not how long a job takes to finish.

5. Gamma: the wait for the k-th event

How long until the third request arrives? That wait is the first gap plus the second gap plus the third gap: a sum of k independent exponentials, each with rate λ. The gamma distribution (the version with whole-number k) is exactly this sum. By the rules of Lesson 12, expectations add, and for independent pieces so do variances:

mean = k × (1/λ) = k / λ
variance = k × (1/λ^2) = k / λ^2

Worked example: waiting for the third request

Requests arrive at λ = 2 per second. A micro-batcher waits until k = 3 requests have arrived before running the model.

mean wait = 3 / 2 = 1.5 s
variance = 3 / 4 = 0.75 → sd = sqrt(0.75) = 0.866 s
P(third request arrives by t = 1.5 s)
= P(at least 3 arrivals in 1.5 s) (Poisson mean = 2 × 1.5 = 3)
= 1 - P(0) - P(1) - P(2)
= 1 - e^(-3) × (1 + 3 + 3^2/2)
= 1 - 0.04979 × 8.5
= 1 - 0.4232 = 0.577

So the batch is full within the mean wait 57.7% of the time, more than half. The distribution is right-skewed: a few unlucky long waits pull the mean above the median. As k grows the hump moves right (mean k/λ), widens (variance k/λ²), and becomes more symmetric and bell-like, the pattern the Central Limit Theorem (Lesson 5) describes for sums. With k = 1 the gamma is just the exponential.

6. Beta: a distribution over a probability

Every shape so far describes a measurement. The beta distribution describes something different: your uncertainty about an unknown probability, a number between 0 and 1. In Lesson 4 a Bernoulli trial has a parameter p, such as a classifier's true accuracy. You never know p exactly; you only see a finite test set. A Beta distribution says which values of p are plausible.

It has two positive parameters, α and β, and lives on [0, 1]:

Beta(α, β): density proportional to x^(α-1) × (1-x)^(β-1) on [0, 1]
mean = α / (α + β)
variance = αβ / ( (α+β)^2 × (α+β+1) )

Two knobs, two jobs. The ratio α:β sets where the hump sits (the mean). The total α + β sets how tightly it clusters. A useful way to read them: α and β behave like counts of successes and failures, so larger counts mean more evidence and a narrower belief.

Beta(α, β)MeanVarianceStd devShape
Beta(1, 1)1/2 = 0.50.08330.289Flat: every accuracy equally plausible (uniform)
Beta(9, 3)9/12 = 0.750.01440.120Leans toward high accuracy, moderately wide
Beta(30, 10)30/40 = 0.750.004570.068Same mean as above, much tighter
00.250.50.7510246possible true accuracy p Beta(1, 1): flat, mean 0.5Beta(9, 3): mean 0.75, sd 0.120Beta(30, 10): mean 0.75, sd 0.068 density

Beta(9, 3) and Beta(30, 10) both center on 0.75. The second says the same thing with far more confidence.

The same mean can carry very different certainty. Integrating each density numerically, the chance the true accuracy lies between 0.70 and 0.80 is about 0.305 under Beta(9, 3) but about 0.535 under Beta(30, 10). A later lesson on Bayesian inference shows how new test results move α and β; this lesson only gives you the shape.

Pitfall A Beta is a distribution over p, not over outcomes. Do not mix up "the model is 75% accurate" (one number, p = 0.75) with "we believe p is around 0.75, give or take 0.12" (a Beta). The first is a Bernoulli parameter. The second is the uncertainty about it.

7. The bell curve is one member of this family

The Normal distribution from Lesson 4 is one more member of this family: a continuous density with mean μ and variance σ², symmetric and spread over the whole number line. Everything above applies to it: probability is area, the CDF accumulates it, percentiles read the CDF backwards. Pick the shape by what the quantity is. A symmetric measurement with no floor suggests Normal; a waiting time suggests exponential or gamma; a value trapped in [0, 1] suggests beta; "any value in a range, no preference" suggests uniform.

8. Why this matters for building AI systems

Why This Matters Almost everything you time, rate, or score is continuous. Choosing the right shape tells you which questions have clean answers.

Recap

Leads into Lesson 14 Every distribution here describes one quantity at a time. A real request has latency and output length and cost, and they move together. Lesson 14 covers joint distributions: how to describe two or more random variables at once, how to recover each one alone, and how to measure the way they vary together.

✅ Check Yourself

1. A latency model assigns a continuous density to response times. What is the probability that a response takes exactly 412.5 ms?

The height of the density curve at 412.5 ms
A small positive number that depends on the standard deviation
Zero. Only ranges of values have probability, given by area under the density

2. On a latency CDF, the curve passes through (1.2 s, 0.95). Which statement is correct?

95% of requests take longer than 1.2 s
The p95 latency is 1.2 s: 95% of requests finish in 1.2 s or less
The average latency is 1.2 s

3. Requests arrive at a steady average rate with independent, exponential gaps. 4 seconds have passed since the last request with no new one. Compared with a fresh start, how long do you expect to wait for the next one?

The same as a fresh start. The exponential is memoryless
Shorter, since a request is now overdue
Longer, since the quiet period suggests traffic has dropped

4. Requests arrive at λ = 2 per second. What are the mean and variance of the wait until the 4th request arrives?

Mean 8 s, variance 16
Mean 0.5 s, variance 0.25
Mean 2 s, variance 1

5. Your belief about a model's true accuracy is Beta(6, 2). What is the mean accuracy, and what happens to the spread if you move to Beta(60, 20)?

Mean 0.25; the spread stays the same
Mean 0.75; the spread shrinks, because the total α+β is larger
Mean 0.75; the spread grows, because the numbers are larger