Erlang's formula and the rates of the loss link
DefinitionKellyStochasticNetworks_ErlangThe model of section 1.3 of Kelly and Yudovina, Stochastic Networks: a single telephone link with parallel circuits and no waiting room.
Calls arrive as a Poisson process of rate . Each call holds one circuit for an exponentially distributed time of parameter , independently of the other calls and of the arrival process. A call that finds all circuits busy is lost. Writing for the number of busy circuits, is a Markov process on with transition rates
every other rate, including , being zero. The upward rate is the Poisson arrival assumption; the downward rate is the rate at which the first of ongoing calls finishes.
Erlang's formula is
equation (1.5) of the book, where is the traffic intensity. Its role is that is the equilibrium probability that all circuits are busy, and hence the probability that an arriving call is lost.
Formalization Note The state space is Fin (C + 1), so the state is the number of busy
circuits and the boundaries and are enforced by the type. The rate matrix is written
as a nested conditional on the integer values of the two indices, which makes q j j = 0
automatic.
import Mathlib
namespace KellyStochasticNetworks
/-- **Erlang's formula.** For a traffic intensity `ν` and `C` circuits,
`E(ν, C) = (ν ^ C / C !) / ∑ j ≤ C, ν ^ j / j !`.
This is equation (1.5) of Kelly–Yudovina, *Stochastic Networks*. -/
noncomputable def erlang (ν : ℝ) (C : ℕ) : ℝ :=
(ν ^ C / (Nat.factorial C : ℝ)) /
∑ j ∈ Finset.range (C + 1), ν ^ j / (Nat.factorial j : ℝ)
/-- **The transition rates of the Erlang loss link** with `C` parallel circuits, calls arriving
as a Poisson process of rate `lam` and call holding times exponential of parameter `mu`.
The state is the number of busy circuits, so `q j (j+1) = lam` for `j < C`,
`q j (j-1) = j * mu` for `j ≥ 1`, and every other rate — including `q j j` — is zero.
These are the rates displayed on p. 18 of Kelly–Yudovina, *Stochastic Networks*. -/
noncomputable def erlangRates (lam mu : ℝ) (C : ℕ) : Fin (C + 1) → Fin (C + 1) → ℝ :=
fun j k =>
if (k : ℕ) = (j : ℕ) + 1 then lam
else if (j : ℕ) = (k : ℕ) + 1 then ((j : ℕ) : ℝ) * mu
else 0
end KellyStochasticNetworks