Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Rayleigh speeds

The speed of a uniformly sampled particle in a two-dimensional equilibrium gas has a Rayleigh distribution. Each signed velocity component is Gaussian; taking the length of the velocity vector changes the law. This answers Taleb’s distribution challenge Taleb, 2026: the density already written in the accompanying animation is Rayleigh Matharium, 2026. No extra physical parameter is needed.

The sampling rule matters. An event recorded when a particle crosses a small hole favors faster particles. We derive the chamber law first, then the effusion law and the finite-system correction. A seeded simulation compares seven fitted families; it illustrates these distinctions without testing whether the animation implements equilibrium dynamics.

From components to speed

Assume a classical, nonrelativistic gas of equal-mass particles at canonical equilibrium, with no bulk flow and no constraint on total momentum. Let m>0m>0 be particle mass, T>0T>0 temperature, and kk Boltzmann’s constant. Let d≥1d\ge1 be an integer. Write the velocity as u∈Rd\mathbf u\in\mathbb R^d, the speed as V=∥u∥V=\|\mathbf u\|, and its realized value as vv. Set

σ2=kTm,c=12σ2.\sigma^2=\frac{kT}{m},\qquad c=\frac1{2\sigma^2}.

Here σ\sigma is component standard deviation; it is not speed standard deviation. Densities below use Lebesgue measure in their stated coordinates. These symbols agree with the shared notation.

For NN particles at positions qi\mathbf q_i and a velocity-independent potential UU, the Hamiltonian is H=∑i=1Nm∥ui∥2/2+U(q1,…,qN)H=\sum_{i=1}^N m\|\mathbf u_i\|^2/2+U(\mathbf q_1,\ldots,\mathbf q_N), and the canonical weight e−H/(kT)e^{-H/(kT)} separates into kinetic and positional factors Tong, n.d., §2.3. Integrating the positions and the other particles leaves the single-particle density

ϕd(u)=(2πσ2)−d/2exp⁡ ⁣(−∥u∥22σ2).\phi_d(\mathbf u) =(2\pi\sigma^2)^{-d/2} \exp\!\left(-\frac{\|\mathbf u\|^2}{2\sigma^2}\right).

The factorization proves that the dd components are independent N(0,σ2)N(0,\sigma^2) variables. This follows from the equilibrium measure; it does not require a central limit argument about collisions. The maximum-entropy note explains why the constraint and the coordinate measure must be specified in an entropy argument.

We now derive the speed density, its moments, and its mode. The surface area of the unit sphere in dd dimensions is Sd−1=2πd/2/Γ(d/2)S_{d-1}=2\pi^{d/2}/\Gamma(d/2). Polar coordinates contribute the shell factor Sd−1vd−1S_{d-1}v^{d-1}, giving

fd(v)=2cd/2Γ(d/2)vd−1e−cv2,v>0.\boxed{ f_d(v)=\frac{2c^{d/2}}{\Gamma(d/2)}v^{d-1}e^{-cv^2},\quad v>0. }

The density is zero for v<0v<0, and V/σ∼χdV/\sigma\sim\chi_d. Substitution t=cv2t=cv^2 gives

∫0∞vd+r−1e−cv2 dv=Γ((d+r)/2)2c(d+r)/2,r>−d.\int_0^\infty v^{d+r-1}e^{-cv^2}\,dv =\frac{\Gamma((d+r)/2)}{2c^{(d+r)/2}},\qquad r>-d.

Taking r=0r=0 proves normalization. For every real r>−dr>-d,

E[Vr]=(2σ2)r/2Γ((d+r)/2)Γ(d/2).\mathbb E[V^r] =(2\sigma^2)^{r/2}\frac{\Gamma((d+r)/2)}{\Gamma(d/2)}.

For r≤−dr\le-d the integral diverges at zero. Every positive moment exists. For d>1d>1, differentiating the log density gives (d−1)/v−v/σ2(d-1)/v-v/\sigma^2, so the unique mode is σd−1\sigma\sqrt{d-1}. For d=1d=1 the law is half-normal and its mode is zero.

DimensionLaw and density for v>0v>0MeanVarianceMode
2Rayleigh: vσ−2e−v2/(2σ2)v\sigma^{-2}e^{-v^2/(2\sigma^2)}σπ/2\sigma\sqrt{\pi/2}(4−π)σ2/2(4-\pi)\sigma^2/2σ\sigma
3Maxwell: 2/π v2σ−3e−v2/(2σ2)\sqrt{2/\pi}\,v^2\sigma^{-3}e^{-v^2/(2\sigma^2)}2σ2/π2\sigma\sqrt{2/\pi}(3−8/π)σ2(3-8/\pi)\sigma^22σ\sqrt2\sigma

In two dimensions, integration also gives F(v)=1−e−v2/(2σ2)F(v)=1-e^{-v^2/(2\sigma^2)} for v≥0v\ge0. This is a Weibull law with shape 2 and scale 2σ\sqrt2\sigma. Its right tail decays faster than any exponential, placing it on the light side of the tail-class catalog.

Generalized Gamma, not GIG

For a local shape s>0s>0, define

hs(v)=2csΓ(s)v2s−1e−cv2,v>0.h_s(v)=\frac{2c^s}{\Gamma(s)}v^{2s-1}e^{-cv^2},\qquad v>0.

This is a generalized Gamma density with power 2; the chamber law has s=d/2s=d/2. The generalized inverse Gaussian GIG family is a different family. In the shared convention its kernel is vp−1exp⁡[−(av+b/v)/2]v^{p-1}\exp[-(av+b/v)/2], with p∈Rp\in\mathbb R and a,b>0a,b>0.

We can exclude Gamma, inverse Gamma, inverse Gaussian, and GIG by their tails, without fitting any data. In the following kernels, shapes and scales are positive, and all parameters are fixed as v→∞v\to\infty.

CandidateDensity kernel on v>0v>0
Gamma, shape s0s_0, scale ϑ\varthetavs0−1e−v/ϑv^{s_0-1}e^{-v/\vartheta}
Inverse Gamma, shape s0s_0, scale b0b_0v−s0−1e−b0/vv^{-s_0-1}e^{-b_0/v}
Inverse Gaussian, mean μ\mu, shape κ\kappav−3/2e−κv/(2μ2)−κ/(2v)v^{-3/2}e^{-\kappa v/(2\mu^2)-\kappa/(2v)}
GIG⁡(p,a,b)\operatorname{GIG}(p,a,b)vp−1e−(av+b/v)/2v^{p-1}e^{-(av+b/v)/2}

After taking logarithms, each candidate has only constant, logarithmic, linear, and reciprocal terms. Consequently, for each such density qq,

lim⁡v→∞log⁡q(v)v2=0,lim⁡v→∞log⁡hs(v)v2=−c<0.\lim_{v\to\infty}\frac{\log q(v)}{v^2}=0, \qquad \lim_{v\to\infty}\frac{\log h_s(v)}{v^2}=-c<0.

The unequal limits prove that none of these fixed-parameter laws equals hsh_s. The argument includes the normalizable Gamma and inverse Gamma boundaries of GIG. Log densities refer to a fixed choice of speed units; changing units changes the negative constant but preserves the distinction.

Gaussian exclusion needs a separate argument: a nondegenerate Gaussian assigns positive probability to negative speeds. Its log-density limit is also negative, so the preceding tail test alone would not exclude it. For d≥2d\ge2, even an ordinary Gaussian conditioned to be nonnegative fails: its density has a positive right limit at zero, whereas fd(0+)=0f_d(0+)=0. Positive support and skewness alone do not identify a family.

Squared speed and energy

Let Q=V2Q=V^2 and let ε=mV2/2\varepsilon=mV^2/2 be kinetic energy. The change of variable from vv to qq has Jacobian 1/(2q)1/(2\sqrt q), so under hsh_s,

pQ(q)=hs(q)2q=csΓ(s)qs−1e−cq,q>0.p_Q(q)=\frac{h_s(\sqrt q)}{2\sqrt q} =\frac{c^s}{\Gamma(s)}q^{s-1}e^{-cq},\qquad q>0.

Using Gamma’s shape, scale convention, this proves

V2∼Gamma⁡(s,2σ2),ε∼Gamma⁡(s,kT).V^2\sim\operatorname{Gamma}(s,2\sigma^2),\qquad \varepsilon\sim\operatorname{Gamma}(s,kT).

For the 2D chamber, s=1s=1: squared speed is exponential with mean 2kT/m2kT/m, and kinetic energy is exponential with mean kTkT. For R=1/QR=1/Q, a second Jacobian gives

pR(r)=csΓ(s)r−s−1e−c/r,r>0.p_R(r)=\frac{c^s}{\Gamma(s)}r^{-s-1}e^{-c/r},\qquad r>0.

Thus 1/V2∼InvGamma⁡(s,c)1/V^2\sim\operatorname{InvGamma}(s,c). Similarly 1/ε1/\varepsilon has inverse Gamma scale 1/(kT)1/(kT). The reciprocal speed 1/V1/V instead has an exponential factor e−c/r2e^{-c/r^2}; it is not inverse Gamma.

If the normalizable boundaries are included, Gamma⁡(s,ϑ)=GIG⁡(s,2/ϑ,0)\operatorname{Gamma}(s,\vartheta)=\operatorname{GIG}(s,2/\vartheta,0) and InvGamma⁡(s,b0)=GIG⁡(−s,0,2b0)\operatorname{InvGamma}(s,b_0)=\operatorname{GIG}(-s,0,2b_0). For the strict a,b>0a,b>0 family these are limits. Transforming a Gamma variable by a square root does not preserve membership in Gamma or GIG.

Crossing a hole changes the sample

Assume the hole is small compared with the mean free path, the gas near it is isotropic and equilibrated, and detection efficiency does not depend on speed. In time dtdt, particles that can cross a small area come from a layer of thickness vcos⁡θ dtv\cos\theta\,dt, where θ\theta is the angle to the outward normal and cos⁡θ>0\cos\theta>0. This is the flux factor in the usual effusion calculation Fitzpatrick, n.d..

Multiplying the equilibrium velocity measure by this factor and integrating over outward directions leaves one extra factor vv. Normalizing proves

gd(v)=vfd(v)EfV=2c(d+1)/2Γ((d+1)/2)vde−cv2,v>0.g_d(v)=\frac{vf_d(v)}{\mathbb E_f V} =\frac{2c^{(d+1)/2}}{\Gamma((d+1)/2)}v^d e^{-cv^2},\qquad v>0.

The effusing speed divided by σ\sigma therefore has law χd+1\chi_{d+1}. In particular,

g2(v)=2πv2σ3e−v2/(2σ2)=f3(v).g_2(v)=\sqrt{\frac2\pi}\frac{v^2}{\sigma^3} e^{-v^2/(2\sigma^2)}=f_3(v).

Two-dimensional effusion has the same speed law as a three-dimensional chamber. The change comes from sampling, not an added spatial dimension. Its mode is σd\sigma\sqrt d, and its squared speed and energy use s=(d+1)/2s=(d+1)/2 in the preceding Gamma formulas. Selecting only an outward direction would not introduce the factor vv; counting crossings does.

The animation shows particles leaving an opening and accumulating in a histogram Matharium, 2026. If those are physical crossing events, the effusion law is the appropriate equilibrium prediction. If the opening merely conveys uniformly selected particles to a histogram, Rayleigh is appropriate. The displayed formula specifies the chamber law; without the sampling algorithm, the drawing does not resolve this distinction.

A finite isolated chamber

Canonical velocities have the preceding Gaussian components even for finite NN. An isolated finite system with fixed total kinetic energy has a different joint measure. Assume N>1N>1 ideal particles, or elastic hard disks or spheres, in reflecting hard walls, with total kinetic energy E>0E>0 and no imposed total-momentum constraint. The velocity measure is uniform on the sphere

∑i=1N∥ui∥2=2Emin RdN.\sum_{i=1}^N\|\mathbf u_i\|^2=\frac{2E}{m} \quad\text{in }\mathbb R^{dN}.

We derive its one-particle marginal. Integrating the remaining d(N−1)d(N-1) coordinates against the energy-shell delta function supplies the factor (E−mv2/2)d(N−1)/2−1(E-mv^2/2)^{d(N-1)/2-1}. The first particle’s radial element contributes vd−1 dvv^{d-1}\,dv. Put vmax⁡=2E/mv_{\max}=\sqrt{2E/m} and B(x,y)=Γ(x)Γ(y)/Γ(x+y)B(x,y)=\Gamma(x)\Gamma(y)/\Gamma(x+y). Substitution z=v2/vmax⁡2z=v^2/v_{\max}^2 normalizes the density to

fN,d(v)=2vd−1vmax⁡dB(d/2,d(N−1)/2)(1−v2vmax⁡2)d(N−1)/2−1,0<v<vmax⁡.f_{N,d}(v)= \frac{2v^{d-1}}{v_{\max}^{d}B(d/2,d(N-1)/2)} \left(1-\frac{v^2}{v_{\max}^2}\right)^{d(N-1)/2-1}, \quad 0<v<v_{\max}.

Equivalently,

mV22E∼Beta⁡ ⁣(d2,d(N−1)2).\boxed{\frac{mV^2}{2E}\sim \operatorname{Beta}\!\left(\frac d2,\frac{d(N-1)}2\right).}

This is a scaled Beta energy law, with a finite upper endpoint Scalas et al., 2015. For the instantaneous effusion measure, multiplication by vv changes the first Beta shape to (d+1)/2(d+1)/2, leaving the second unchanged.

Define the kinetic temperature by E=dNkTkin/2E=dNkT_{\rm kin}/2. At fixed TkinT_{\rm kin} and fixed speed, the finite-system factor tends to e−mv2/(2kTkin)e^{-mv^2/(2kT_{\rm kin})} as N→∞N\to\infty, and the Gamma-ratio asymptotic Γ(z+a)/Γ(z)∼za\Gamma(z+a)/\Gamma(z)\sim z^a gives the canonical normalizer. This proves the chi limit; it is not a uniform relative approximation all the way to vmax⁡v_{\max}. Fixing total momentum as well would change the available degrees of freedom and the Beta law.

Hard-core exclusion affects the allowed positions but introduces no velocity-dependent potential, so it does not alter the canonical factorization. Elastic collisions conserve energy; that alone does not prove that an arbitrary initial condition has equilibrated. Noninteracting point particles reflecting in a fixed box retain their individual speeds.

Leaking cools the chamber

The moment formula gives mean energy dkT/2dkT/2 inside and (d+1)kT/2(d+1)kT/2 among effusing particles. A leak therefore removes more energy per particle than the chamber average. In a large, unheated chamber that re-equilibrates between losses, treat NN as continuous and use dots for time derivatives. Energy balance gives

d2k(NT˙+TN˙)=d+12kTN˙,NT˙=TN˙d.\frac d2 k(N\dot T+T\dot N) =\frac{d+1}{2}kT\dot N, \qquad N\dot T=\frac{T\dot N}{d}.

Since N˙<0\dot N<0, temperature falls. Starting at N0,T0N_0,T_0, integration gives T/T0=(N/N0)1/dT/T_0=(N/N_0)^{1/d} within this quasistatic approximation. If the outgoing event rate is J(t)J(t), the accumulated speed density over an observation interval is

hcollected(v)=∫J(t)gd(v;T(t)) dt∫J(t) dt.h_{\rm collected}(v)= \frac{\int J(t)g_d(v;T(t))\,dt}{\int J(t)\,dt}.

It generally mixes temperatures. The variance-mixture note explains why averaging over scales can change a marginal law. A fixed-temperature effusion density does not describe an entire cooling history.

A reproducible comparison

We draw 50,000 independent pairs of Gaussian components with kT/m=1kT/m=1, seed 20261022, and take their Euclidean lengths. All first components are drawn before all second components. This samples the canonical chamber law directly; it is neither molecular dynamics nor a sample extracted from the animation.

We fit Gaussian, Gamma, inverse Gamma, inverse Gaussian, GIG, Rayleigh, and Weibull laws by maximum likelihood. Positive families have location fixed at zero. Gaussian estimates mean and standard deviation; Rayleigh estimates one scale; Weibull, Gamma, and the two inverse families estimate two parameters. With KK estimated parameters and maximized log likelihood ℓ\ell, the reported score is AIC=2K−2ℓ\mathrm{AIC}=2K-2\ell in these fixed speed units.

Two vertical panels compare the simulated speed histogram with seven fitted densities on linear and logarithmic scales; the Gaussian extends below zero and the inverse families overstate the far right tail.

The same 50,000 speeds in 80 bins. Curves use 401 points from -0.5 to the sample maximum. The log panel displays densities down to 10-5; this plotting limit does not truncate the fitted laws. Rayleigh and Weibull nearly coincide, as do Gamma and the GIG boundary fit.

The table’s KS distance is D=sup⁡v∣Fn(v)−Fθ^(v)∣D=\sup_v|F_n(v)-F_{\hat\theta}(v)|, where FnF_n is the empirical CDF. Its p-values are the ordinary two-sided KS calculation without correction for parameter fitting. They are descriptive diagnostics, not calibrated tests of the fitted families. Calibration would require, for example, a parametric bootstrap with refitting in each replicate SciPy developers, 2026. Zeros below are numerical underflow, not exact zero probabilities.

Use sample_chi_speed, fit_speed_models, speed_fit_table, and squared_speed_ks.

Code and fit table
from xmath.incerto.gas_speeds import (
    sample_chi_speed, fit_speed_models, speed_fit_table, squared_speed_ks,
)

v = sample_chi_speed(50_000, random_state=20261022)
fits = fit_speed_models(v)
print(speed_fit_table(fits))
energy = squared_speed_ks(v, thermal_variance=1)
print(f"V^2 vs Exp(mean 2): D={energy['statistic']:.4f}, p={energy['pvalue']:.4f}")
for fit in fits:
    if fit.boundary:
        print(f"{fit.name} boundary: {fit.boundary}")

Output

Model              K        AIC     KS D   KS p (raw)
Rayleigh           1    93781.3   0.0034        0.618
Weibull            2    93783.3   0.0035        0.585
Gamma              2    95323.5   0.0327     5.43e-47
GIG                3    95325.5   0.0327     5.43e-47
Gaussian           2    99241.9   0.0471     5.06e-97
inverse Gaussian   2   110562.7   0.1170            0
inverse Gamma      2   123078.8   0.1338            0
V^2 vs Exp(mean 2): D=0.0058, p=0.0696
GIG boundary: Gamma

The Rayleigh scale estimate is about 0.9967. Weibull estimates shape 2.0014, close to Rayleigh’s exact shape 2; its extra parameter raises AIC by about 2. These are finite-sample fits, not a new derivation of the law.

Why the GIG fit lands on Gamma

The Gamma MLE has shape s^=3.1513\hat s=3.1513 and scale ϑ^=0.3964\hat\vartheta=0.3964. At its GIG representation (p,a,b)=(s^,2/ϑ^,0)(p,a,b)=(\hat s,2/\hat\vartheta,0), the inward derivative of log likelihood per observation is

1n∂ℓ∂b∣b=0+=12(1(s^−1)ϑ^−1n∑i=1n1vi)<0.\left.\frac1n\frac{\partial\ell}{\partial b}\right|_{b=0+} =\frac12\left( \frac1{(\hat s-1)\hat\vartheta} -\frac1n\sum_{i=1}^n\frac1{v_i}\right)<0.

This expression is finite because s^>1\hat s>1. Differentiating the normalizing integral supplies the model reciprocal mean in the first term. The other two score components vanish at the Gamma MLE. Log likelihood is concave in the natural coordinates (p−1,−a/2,−b/2)(p-1,-a/2,-b/2): the Hessian of its log normalizer is the covariance of (log⁡V,V,1/V)(\log V,V,1/V) in the interior. The supporting-plane inequality therefore certifies a maximum on the Gamma boundary. For strict a,b>0a,b>0, this value is a supremum as b↓0b\downarrow0.

The helper uses that boundary law directly for its density and CDF. It does not present tiny positive GIG parameters as a distinct distribution. The table retains GIG’s nominal K=3K=3, hence a score exactly 2 above Gamma’s. Ordinary regular-model AIC theory does not apply unchanged at this boundary; the score here is a stated comparison convention.

Quantiles and the squared-speed check

Five vertically stacked QQ panels group Rayleigh and Weibull, Gaussian with Gamma and GIG, the inverse Gaussian, the inverse Gamma, and squared speeds against an exponential law. The first and last panels follow the equality line closely.

Theoretical quantiles are horizontal and empirical quantiles vertical, at 199 equally spaced probabilities from 0.005 to 0.995. The inverse-family panels need different horizontal ranges because their predicted upper quantiles are much larger. All displayed quantiles are retained. These QQ plots use the same observations as the fit table; they are not independent validation data.

The squared-speed test compares against the specified exponential mean 2, without estimating it. Its KS statistic is 0.0058 and its p-value is 0.0696, so it does not reject this simple null at the 5% level. This p-value has the usual iid continuous-null calibration. It is not the probability that the exponential model is true. The different Rayleigh p-value in the table uses a fitted scale.

chi_speed provides the model density and CDF; speed_qq constructs quantile pairs. The two figures come from speed_fit_figure, using the shared set_theme, vertical_figure, and savefig helpers. Regenerate them with uv run python demos/incerto/rayleigh_speed.py. The page’s text output is regenerated by uv run python scripts/regenerate_incerto_outputs.py.

References

Browse the distribution catalog for related laws and the API reference for the reproducible calculations.

References
  1. Taleb, N. N. (2026). A challenge about the distribution of gas speeds. X post, 22 October. https://x.com/nntaleb/status/2113276779041345936
  2. Matharium. (2026). Two-dimensional Maxwell–Boltzmann speed animation. X post, 22 October. https://x.com/matharium/status/2113194382883197403
  3. Tong, D. (n.d.). Statistical Physics: Classical Gases. University of Cambridge lecture notes, section 2.3. https://www.damtp.cam.ac.uk/user/tong/statphys/statmechhtml/S2.html
  4. Fitzpatrick, R. (n.d.). Effusion. University of Texas at Austin thermal physics notes. https://farside.ph.utexas.edu/teaching/sm1/Thermalhtml/node88.html
  5. Scalas, E., Gabriel, A. T., Martin, E., & Germano, G. (2015). Velocity and Energy Distributions in Microcanonical Ensembles of Hard Spheres. Physical Review E, 92(2), 022140. https://arxiv.org/abs/1207.3505v2
  6. SciPy developers. (2026). scipy.stats.goodness_of_fit. SciPy API reference. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.goodness_of_fit.html