Calculating the expected range of normal samples
(832) 422-8646
Contact
The previous post looked at the expected IQ range in a jury of 12. This post will look more generally at computing the expected range of n samples from a N(0, 1) random variable. This will give the expected range in units of σ, i.e. multiply the results by σ if your σ isn’t 1.
As mentioned in the previous post, the expected range is given by
where φ and Φ are the PDF and CDF of a standard normal. The integral can be calculated in closed form for n ≤ 5, but in general it requires numerical integration [1].
The following Python code can compute dn.
from scipy.stats import norm<br>from scipy.integrate import quad<br>import numpy as np
def d(n):<br>integrand = lambda x: x*norm.pdf(x)*norm.cdf(x)**(n-1)<br>res, info = quad(integrand, -np.inf, np.inf)<br>return 2*n*res
For large n we have the asymptotic approximation
which we could implement in Python by
def approx(n):<br>return 2*norm.ppf((n - 0.375)/(n + 0.25))
For very large n the asymptotic expression may be more accurate than the integral due to numerical integration error.
Here are a few example values.
|-----+-------|<br>| n | d_n |<br>|-----+-------|<br>| 2 | 1.128 |<br>| 3 | 1.693 |<br>| 5 | 2.326 |<br>| 10 | 3.078 |<br>| 12 | 3.258 |<br>| 23 | 3.858 |<br>| 50 | 4.498 |<br>| 100 | 5.015 |<br>|-----+-------|
[1] Order Statistics by H. A. David. John Wiley & Sons. 1970.
One thought on “Calculating the expected range of normal samples”
Blaise F Egan
26 May 2026 at 15:38
I just asked Microsoft Copilot to create the code for Mathematica (which I have, but I am a complete newbie at). I was amazed at how easy it was.
Create Mathematica code to numerically evaluate the integral, for n=12, of $2*n* \int_{-infty}^ {infty} \Phi(x)^{n-1} *x*\phi(x) dx$
where $\Phi(x)$ is the CDF of the standard normal and $\phi(x)$ is the PDF.
It gave me
n = 12;
Φ[x_] := CDF[NormalDistribution[], x];
φ[x_] := PDF[NormalDistribution[], x];
N[ 2 n NIntegrate[ Φ[x]^(n – 1) * x * φ[x], {x, -∞, ∞},
Method -> "GlobalAdaptive", WorkingPrecision -> 30 ],
20
It ran for a fraction of a second and gave me:
3.2584552797438259806
with comments:
Notes on the implementation
WorkingPrecision -> 30 ensures numerical stability because the integrand involves a product of a CDF power and a PDF.
Method -> "GlobalAdaptive" helps with tails and smoothness.
The integral converges rapidly, so {-∞, ∞} is fine; Mathematica handles the truncation automatically.
Leave a Reply<br>Your email address will not be published. Required fields are marked *<br>Comment *<br>Name *
Email *
Website
Search for:
John D. Cook, PhD
My colleagues and I have decades of consulting experience helping companies solve complex problems involving data privacy, applied math, and statistics.
Let’s talk. We look forward to exploring the opportunity to help your company too.