LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
fj_xmax_erlang.h File Reference

Expected maximum of K i.i.d. More...

Include dependency graph for fj_xmax_erlang.h:

Go to the source code of this file.

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::fj

Functions

template<class T>
T line::fj::fj_xmax_erlang (unsigned K, unsigned k, const T &mu)
 Expected maximum of K i.i.d.

Detailed Description

Expected maximum of K i.i.d.

Erlang-k service times.

Templated port of matlab/src/api/fj/fj_xmax_erlang.m, cross-checked against FJ_xmax.fj_xmax_erlang in jar/src/main/java/jline/api/fj/FJ_xmax.java (identical formulas; the JAR replaces MATLAB's adaptive integral with a 10001-point composite Simpson rule, which this port also does).

MIXED ARITHMETIC. At k = 2 the MATLAB file uses the closed form

X_K^max = (1/mu) sum_{n=1..K} C(K,n) (-1)^{n-1} sum_{m=0..n} C(n,m) m! / n^{m+1}

the inner sum being int_0^inf S(t)^n dt for S(t) = e^{-mu t}(1 + mu t). Until 2026-11-14 every codebase started the inner sum at m = 1 and divided by an extra 2, giving 1/(2 mu) at K = 1 instead of the Erlang-2 mean 2/mu.

which is rational and therefore exact in any field, cancellation included: the alternating outer sum is exactly the kind that double cannot carry past about K = 25. For any other k the mean is a quadrature of 1 - F(t)^K against the Erlang CDF and needs exp, so it is only available when T carries transcendental functions; asking for it at exact arithmetic throws UnsupportedError rather than silently substituting something else.

Definition in file fj_xmax_erlang.h.