2 % @brief Expected maximum
using EMMA method
4 % @author LINE Development Team
8 % @brief Expected maximum
using EMMA method
11 % Computes the expected value of the maximum of K i.i.d. random variables
12 %
using the EMMA (Expected Maximum from Marginal Approximation) method.
14 % The method
is based on the
property that:
15 % [F_X(E[Y_K])]^K ≈ φ = 0.570376
18 % E[Y_K] ≈ F^{-1}(φ^{1/K})
20 % For the exponential distribution with rate μ:
21 % E[Y_K] = -(1/μ) * ln(1 - φ^{1/K})
23 % The constant φ = exp(-exp(-γ)) ≈ 0.570376, where γ ≈ 0.5772
is the
24 % Euler-Mascheroni constant.
28 % Xmax = fj_xmax_emma(K, mu) % Exponential with rate mu
29 % Xmax = fj_xmax_emma(K, F_inv) % General CDF inverse
30 % Xmax = fj_xmax_emma(K, mu,
'exp') % Explicit exponential
31 % Xmax = fj_xmax_emma(K, F_inv,
'general') % Explicit general
36 % <tr><th>Name<th>Description
37 % <tr><td>K<td>Number of random variables (positive integer)
38 % <tr><td>param<td>Rate mu for exponential, or inverse CDF function handle
39 % <tr><td>dist_type<td>Optional:
'exp' (default) or
'general'
44 % <tr><th>Name<th>Description
45 % <tr><td>Xmax<td>Approximate expected maximum E[Y_K]
49 % A. Thomasian,
"Analysis of Fork/Join and Related Queueing Systems",
50 % ACM Computing Surveys, Vol. 47, No. 2, Article 17, July 2014.
51 % Eq. (44) on page 17:22.
53 % Original: Y. Sun, K.L. Peterson,
"Computing Extreme Order Statistics from
54 % Large Data Sets", 2012.
56function Xmax = fj_xmax_emma(K, param, dist_type)
58% EMMA constant: φ = exp(-exp(-γ)) where γ
is Euler-Mascheroni constant
62 % Determine type from param
63 if isa(param,
'function_handle')
64 dist_type = 'general';
71 line_error(mfilename, 'K must be a positive integer. Got K=%d.', K);
74switch lower(dist_type)
76 % Exponential distribution with rate mu
79 line_error(mfilename, 'Rate mu must be positive.');
81 % E[Y_K] = -(1/mu) * ln(1 - phi^(1/K))
82 Xmax = -(1 / mu) * log(1 - phi^(1 / K));
85 % General distribution: param
is the inverse CDF (quantile function)
87 if ~isa(F_inv, 'function_handle')
88 line_error(mfilename, 'For general distribution, param must be a function handle for the inverse CDF.');
90 % E[Y_K] = F^{-1}(phi^{1/K})
91 Xmax = F_inv(phi^(1 / K));
94 line_error(mfilename,
'Unknown distribution type: %s. Valid: exp, general.', dist_type);