---
title: Extremes and crest factor
heading: The largest and smallest of many, and how big noise peaks get
eyebrow: A11 · Lesson 18 · Extremes
xp: 40
---

::: hook
Engineers often care less about a typical value than about the worst one: the first of many parts to fail, the highest noise peak in a second of samples, the slowest of a thousand logic paths. These are **extremes**, the maximum or minimum of many random values, and they follow simple rules. The largest of $n$ values is below $x$ only if every one of them is, so its CDF is the single value's CDF raised to the power $n$. That one idea explains why big systems fail early and why a noise signal's peaks sit five or six standard deviations out.
:::

::: play
- The curve is the density of the largest of $n$ independent values, each uniform on $[0, 1]$: $nx^{n-1}$.
- With $n = 1$ it's flat. Raise $n$: the density piles up near 1, because with many draws, one of them is almost certainly large.
- The readout gives the mean of the maximum, $\frac{n}{n + 1}$.
:::

```sim plot
view: graph
x: x = 0..1
y: density = 0..20
slider: n = 1..20 step 1 = 5
plot: n*x^(n - 1) | label: density of the maximum | samples: 400
readout: mean of the maximum = n/(n + 1) | digits: 4
readout: chance the maximum is below 0.9 = 0.9^n | digits: 4
```

::: predict
## A system has 3 parts, each with an exponential lifetime of mean 10 years. When, on average, does the first one fail?

- [ ] After 10 years
- [ ] After 30 years
- [x] After about 3.3 years
- [ ] After 5 years

::: reveal
After $\frac{10}{3} = 3.3$ years. The minimum of independent exponential lifetimes is exponential too, with the failure rates added: three parts at 0.1 per year give 0.3 per year. Every redundant part you add without spares makes the first failure come sooner, which is why large systems need maintenance plans built around their weakest-link rate.
:::
:::

::: nameit
## The maximum and the minimum

For $n$ independent values with the same CDF $F(x)$:

$$P(\max \le x) = F(x)^n, \qquad P(\min > x) = (1 - F(x))^n$$

The maximum's density is $nF(x)^{n-1}f(x)$.

## Exponential lifetimes

If each part fails at rate $\lambda$, the first failure among $n$ parts comes at rate $n\lambda$, with mean $\frac{1}{n\lambda}$. With different rates, the rates add: the series-system failure rate is the sum of its parts' rates.

## Noise peaks and crest factor

A noise waveform's **crest factor** is its peak divided by its RMS. For Gaussian noise there's no hard peak, but over $n$ independent samples the chance that all stay within $\pm k\sigma$ is $(1 - 2Q(k))^n$. For a million samples, $k = 5$ gives about even odds; so a scope capturing a million noise samples typically shows peaks near $\pm5\sigma$, and peak-to-peak readings of about $10\sigma$ for a long record. Converters and amplifiers are given headroom for those peaks.

## Worst-case paths

A chip's clock period is set by its slowest path. If thousands of paths each have a little random delay variation, the maximum sits several standard deviations above the typical path, so statistical timing analysis looks at the tail, not the mean.
:::

::: example
## Three parts each have exponential lifetimes with a mean of 10 years. What is the mean time to the first failure?

::: solution
1. **Combined rate.** Each fails at rate 0.1 per year, so the first of the three fails at rate 0.3 per year.
2. **Mean time to the first failure.** That's an exponential with mean
   $$\frac{1}{0.3} = 3.33\ \text{years}$$
3. **All three last 5 years.**
   $$e^{-0.3 \times 5} = 0.22$$
   against $e^{-0.5} = 0.61$ for one part.

**Answer:** the first failure comes after 3.33 years on average.
:::
:::

::: example
## Gaussian noise is sampled a million times. What is the chance that every sample stays within ±5σ?

::: solution
1. **One sample.** Each sample exceeds $\pm5\sigma$ with probability
   $$2Q(5) = 5.7 \times 10^{-7}$$
2. **A million samples.** All million stay inside with probability
   $$\begin{aligned} P &= (1 - 5.73 \times 10^{-7})^{10^6} \\ &\approx e^{-0.573} \\ &= 0.56 \end{aligned}$$
3. **What it means.** In a million samples, peaks beyond $5\sigma$ are roughly a coin toss; in ten million, they're almost certain.

**Answer:** every sample stays within ±5σ with chance 0.56.
:::
:::

::: example
## Nine values are uniform on $[0, 1]$. What is the mean of the largest, and the chance it's below 0.9?

::: solution
1. **Mean of the largest.** The mean of the maximum of $n$ uniforms is
   $$\frac{n}{n + 1} = 0.9$$
2. **All nine below 0.9.**
   $$0.9^9 = 0.387$$
3. **What it means.** The maximum is above 0.9 more often than not, even though each value is below 0.9 nine times in ten.

**Answer:** the largest has mean 0.9, and it is below 0.9 with chance 0.387.
:::
:::

::: check
given: n = 2 | 5 | 10; m = 5 | 20
answer: m/n
unit: years
tolerance: 0.5%

## {n} parts each have an exponential lifetime with a mean of {m} years. When, on average, does the first fail?

::: right
Right. The rates add to $\frac nm$ per year, so the mean is $\frac mn$ = {answer}.
:::

::: misses
- [m] That's one part alone; with {n}, the first failure comes sooner.
- [m*n] That's the total of all lifetimes, not the first failure.
- [any] Not yet. The minimum of exponentials is exponential with the rates added.
:::
:::

::: check
given: n = 5 | 10 | 20; x = 0.8 | 0.95
answer: x^n
tolerance: 0.5%

## {n} independent values are uniform on $[0, 1]$. What is the chance the largest is below {x}?

::: right
Right. All {n} must be below {x}: $x^n$ = {answer}.
:::

::: misses
- [1 - x^n] That's the chance the largest is above it.
- [x] That's for one value.
- [any] Not yet. $P(\max \le x) = F(x)^n$.
:::
:::

::: check
given: k = 4 | 5; n = 1000 | 1000000
answer: 1 - (1 - 2*Q(k))^n
tolerance: 1%

## Gaussian noise is sampled {n} times. What is the chance that at least one sample exceeds ±{k}σ?

::: right
Right. $1 - (1 - 2Q(k))^n$ = {answer}.
:::

::: misses
- [2*Q(k)] That's for one sample.
- [any] Not yet. Take the complement of all samples staying inside.
:::
:::

::: check
given: n = 3 | 9 | 19
answer: n/(n + 1)
tolerance: 0.5%

## What is the mean of the largest of {n} values uniform on $[0, 1]$?

::: right
Right. $\frac{n}{n + 1}$ = {answer}.
:::

::: misses
- [1/(n + 1)] That's the mean of the smallest.
- [any] Not yet. Integrate $x \cdot nx^{n-1}$ from 0 to 1.
:::
:::

::: check
kind: parts
given: l1 = 0.1 | 0.2; l2 = 0.05 | 0.3; t = 2 | 5

## A board fails if either of two parts fails; their failure rates are {l1} and {l2} per year.

::: part
answer: exp(-(l1 + l2)*t)
tolerance: 0.5%

### What is the chance the board survives {t} years?

::: misses
- [exp(-l1*t) + exp(-l2*t)] Both must survive: multiply.
- [any] $e^{-\lambda_1t}e^{-\lambda_2t}$.
:::
:::

::: part
answer: 1/(l1 + l2)
unit: years
tolerance: 0.5%

### What is its mean life?

::: misses
- [any] The rates add.
:::
:::
:::

::: check
kind: derivation
vars: n = 1..20, x = 0..1

## Find the density of the largest of $n$ uniform values on $[0, 1]$.

::: step
answer: x^n

### What is its CDF, $P(\max \le x)$?
:::

::: step
answer: n*x^(n - 1)

### Differentiate. What is its density?
:::

::: right
Right. $nx^{n-1}$, crowding toward 1 as $n$ grows.
:::
:::

::: check
kind: python

## Simulate 10⁵ systems of 3 parts, each with an exponential life of mean 10 years (`np.random.default_rng(1)`), and set `first` to the mean time to the first failure.

```python starter
import numpy as np

first = 10.0
print(first)
```

```python solution
import numpy as np

rng = np.random.default_rng(1)
life = rng.exponential(10, (10**5, 3))
first = life.min(axis=1).mean()
print(first)
```

```python tests
assert abs(first - 10 / 3) < 0.05, f"The first of three fails after 10/3 = 3.33 years on average; got {first}."
```

::: right
Right. 3.33 years: the minimum of exponentials is exponential with the rates added.
:::
:::

::: explain
## Why does adding more components to a system without redundancy make it fail sooner, even if each component is excellent?

::: model
A series system works only while every component works, so its lifetime is the minimum of the components' lifetimes. The minimum of many random values sits near the low end of their spread, and the more values there are, the lower it goes. For constant failure rates the effect is exact: the system's failure rate is the sum of its parts' rates, so a thousand parts each failing once per million hours give a system that fails once per thousand hours. Excellent parts help, but only redundancy, which lets the system survive individual failures, breaks the link between part count and failure rate.
:::
:::

::: practice

::: check
given: n = 2..100 int; m = 1..50
answer: m/n
tolerance: 0.5%

## Mean time to first failure, {n} parts each with mean life {m}?

::: misses
- [any] $\frac mn$.
:::
:::

::: check
given: n = 2..50 int; x = 0.5..0.99
answer: x^n
tolerance: 0.5%

## Chance the largest of {n} uniforms is below {x}?

::: misses
- [any] $x^n$.
:::
:::
:::
