LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fj_xmax_emma.m
1%{ @file fj_xmax_emma.m
2 % @brief Expected maximum using EMMA method
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Expected maximum using EMMA method
9 %
10 % @details
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.
13 %
14 % The method is based on the property that:
15 % [F_X(E[Y_K])]^K ≈ φ = 0.570376
16 %
17 % Therefore:
18 % E[Y_K] ≈ F^{-1}(φ^{1/K})
19 %
20 % For the exponential distribution with rate μ:
21 % E[Y_K] = -(1/μ) * ln(1 - φ^{1/K})
22 %
23 % The constant φ = exp(-exp(-γ)) ≈ 0.570376, where γ ≈ 0.5772 is the
24 % Euler-Mascheroni constant.
25 %
26 % @par Syntax:
27 % @code
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
32 % @endcode
33 %
34 % @par Parameters:
35 % <table>
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'
40 % </table>
41 %
42 % @par Returns:
43 % <table>
44 % <tr><th>Name<th>Description
45 % <tr><td>Xmax<td>Approximate expected maximum E[Y_K]
46 % </table>
47 %
48 % @par Reference:
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.
52 %
53 % Original: Y. Sun, K.L. Peterson, "Computing Extreme Order Statistics from
54 % Large Data Sets", 2012.
55%}
56function Xmax = fj_xmax_emma(K, param, dist_type)
57
58% EMMA constant: φ = exp(-exp(-γ)) where γ is Euler-Mascheroni constant
59phi = 0.570376;
60
61if nargin < 3
62 % Determine type from param
63 if isa(param, 'function_handle')
64 dist_type = 'general';
65 else
66 dist_type = 'exp';
67 end
68end
69
70if K < 1
71 line_error(mfilename, 'K must be a positive integer. Got K=%d.', K);
72end
73
74switch lower(dist_type)
75 case 'exp'
76 % Exponential distribution with rate mu
77 mu = param;
78 if mu <= 0
79 line_error(mfilename, 'Rate mu must be positive.');
80 end
81 % E[Y_K] = -(1/mu) * ln(1 - phi^(1/K))
82 Xmax = -(1 / mu) * log(1 - phi^(1 / K));
83
84 case 'general'
85 % General distribution: param is the inverse CDF (quantile function)
86 F_inv = param;
87 if ~isa(F_inv, 'function_handle')
88 line_error(mfilename, 'For general distribution, param must be a function handle for the inverse CDF.');
89 end
90 % E[Y_K] = F^{-1}(phi^{1/K})
91 Xmax = F_inv(phi^(1 / K));
92
93 otherwise
94 line_error(mfilename, 'Unknown distribution type: %s. Valid: exp, general.', dist_type);
95end
96
97end