Mathematical models for terrain slope distributions derived from first principles in Mathematical Geoenergy (GEM), Chapter 16 (Gravitational Potential Energy: Terrain and Topography).
The terrain slope distribution is a prime example of a super-statistical Maximum Entropy (MaxEnt) dispersion problem. The derivation in GEM Ch. 16 starts from two elementary observations:
Combining these two facts by integrating over all possible mean energies yields the Bessel-$K_0$ distribution for terrain slope. This matches the cumulative slope histogram from approximately 5 billion slope points computed from the USGS 1:250,000 DEM data set (92-metre post intervals, lower 48 US states), with only a single free parameter: the mean slope $S_0 = 0.039$ (≈ 4% grade).
Eq. 16-46 — MaxEnt conditional slope PDF
\[p(S \mid E) = \frac{1}{cE}\cdot e^{-S/(cE)}, \quad S \geq 0\]Applying Maximum Entropy with a known local mean energy $E$ gives an exponential distribution for slope $S$. The constant $c$ links energy to slope magnitude (units: slope / energy); the conditional mean is $cE$.
Eq. 16-47 — MaxEnt energy prior
\[p(E) = k\cdot e^{-kE}, \quad E \geq 0\]The local mean energy $E$ also varies across the landscape. Applying MaxEnt with only a known mean $1/k$ gives an exponential prior for $E$. This is the super-statistics step.
Eq. 16-48 — Marginal (super-statistics) integral
\[p(S) = \int_0^\infty p(S \mid E)\cdot p(E)\\,dE\]Integrating the conditional slope PDF over the energy prior:
\[= \frac{k}{c}\int_0^\infty \frac{1}{E}\cdot e^{-S/(cE) - kE}\\,dE\]Eq. 16-49 — Bessel-$K_0$ slope PDF
\[p(S) = \frac{2}{S_0}\cdot K_0\left(2\sqrt{\frac{S}{S_0}}\right)\]Closed-form result of the marginal integral (Eq. 16-48), using the standard identity $\int_0^\infty E^{-1} e^{-a/E - bE}\,dE = 2K_0(2\sqrt{ab})$ with $a = S/c$ and $b = k$.
The scale parameter is $S_0 = c/k$ (mean slope). Properties:
Complementary CDF (fraction of slopes exceeding $s$):
\[P(S > s) = 2\sqrt{\frac{s}{S_0}}\cdot K_1\left(2\sqrt{\frac{s}{S_0}}\right)\]This identical functional form also appears as the wind super-statistics CDF (GEM Ch. 11, Eq. 11-15), demonstrating the universal character of the super-statistical MaxEnt argument.
Algorithm (GEM Ch. 16)
To draw random slope samples without inverting the Bessel-$K_0$ CDF:
Why it works: the product $Z = X_1 \cdot X_2$ of two i.i.d. $\text{Exp}(1)$ variates has PDF $f(z) = 2K_0(2\sqrt{z})$. Scaling by $S_0$ gives $p(S) = (2/S_0)\cdot K_0(2\sqrt{S/S_0})$ (Eq. 16-49).
Eq. 16-24 — MaxEnt terrain segment length distribution
\[P(L) = \frac{1}{\langle L \rangle}\cdot e^{-L/\langle L \rangle}\]Applying MaxEnt to the length of terrain plateau/valley segments yields an exponential distribution with mean $\langle L \rangle$.
Eq. 16-25 — Characteristic function (Fourier transform of Eq. 16-24)
\[P(S_x) = \frac{1}{1 + i\cdot S_x\cdot\langle L \rangle}\]Eq. 16-26 — Lorentzian (Cauchy) terrain PSD
\[I_0(S_x) = \frac{1}{4 + \langle L \rangle^2\cdot S_x^2}\]This is the $|P(S_x)|^2$ spectral density for the incoherent Markov terrain model. Its $1/S_x^2$ high-frequency roll-off is the hallmark of a second-order random process, consistent with measured DEM and vehicle test-track PSD data.
The corresponding autocorrelation function is:
\[C(x) = e^{-2|x|/\langle L \rangle} = e^{-\alpha_c|x|}\]with half-width $\alpha_c = 2/\langle L \rangle$.
| File | Purpose |
|---|---|
terrain_symbolic.py |
Symbolic derivation of all equations using SymPy |
terrain_numerical.py |
Numerical implementation, validation, and composite figure |
terrain_model_output.png |
Output figure (6 panels) generated by terrain_numerical.py |
Install dependencies (from models/requirements.txt):
pip install -r ../requirements.txt
Run symbolic derivation (all assertions print ✓):
python terrain_symbolic.py
Run numerical model and generate figure:
MPLBACKEND=Agg python terrain_numerical.py
Single-parameter model: the Bessel-$K_0$ distribution has only one free parameter ($S_0$, the mean slope), determined from observed data. No curve-fitting is needed beyond this single number.
Two MaxEnt priors combine to give Bessel-$K_0$: an exponential conditional distribution for slope (Eq. 16-46) combined with an exponential prior for energy (Eq. 16-47) integrates to the Bessel-$K_0$ PDF (Eq. 16-49). Compare with GEM Ch. 15 (lakes), where two exponentials also combine but produce a Lomax distribution.
Stretched-exponential tail: for large $S$, the PDF falls off as $e^{-2\sqrt{S/S_0}}$, slower than a pure exponential but faster than a power law. This matches the intermediate behaviour observed in terrain data and noted in the stretched exponential literature.
Universal Bessel-$K$ functional form: the complementary CDF $P(S > s) = 2\sqrt{s/S_0}\cdot K_1(2\sqrt{s/S_0})$ is identical to the wind energy super-statistics CDF (GEM Ch. 11, Eq. 11-15). This reflects the same underlying super-statistical MaxEnt structure in both phenomena.
Simple Monte Carlo: the slope distribution is easily sampled via the product of two natural-log-uniform draws — no CDF inversion required.
Lorentzian terrain PSD: the $1/S_x^2$ power-law roll-off of the Markov terrain PSD (Eq. 16-26) is universal for surfaces with exponentially distributed correlation lengths, consistent with vehicle test-track and DEM measurements worldwide.