LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fj_xmax_normal.m
1%{ @file fj_xmax_normal.m
2 % @brief Expected maximum for normal distribution
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Expected maximum for normal distribution
9 %
10 % @details
11 % Computes the expected value of the maximum of K i.i.d. normal random
12 % variables using the approximation from Johnson et al. [1995].
13 %
14 % E[Y_K] ≈ μ + σ * [sqrt(2*ln(K)) - (ln(ln(K)) - ln(4π) + 2γ) / (2*sqrt(2*ln(K)))]
15 %
16 % where γ ≈ 0.5772 is the Euler-Mascheroni constant.
17 %
18 % A bias correction from Petzold [2000] can be applied:
19 % δ(K) = 0.1727 * K^(-0.2750)
20 %
21 % The variance of the maximum is approximately:
22 % Var[Y_K] ≈ 1.64492 * σ^2 / (2*ln(K))
23 %
24 % A simpler approximation from Arnold [1980] is also available:
25 % E[Y_K] ≈ μ + σ * sqrt(2*ln(K))
26 %
27 % @par Syntax:
28 % @code
29 % Xmax = fj_xmax_normal(K, mu, sigma)
30 % Xmax = fj_xmax_normal(K, mu, sigma, 'johnson') % Johnson et al. (default)
31 % Xmax = fj_xmax_normal(K, mu, sigma, 'arnold') % Arnold approximation
32 % Xmax = fj_xmax_normal(K, mu, sigma, 'corrected') % With Petzold correction
33 % [Xmax, Vmax] = fj_xmax_normal(...) % Also return variance
34 % @endcode
35 %
36 % @par Parameters:
37 % <table>
38 % <tr><th>Name<th>Description
39 % <tr><td>K<td>Number of random variables (positive integer >= 2)
40 % <tr><td>mu<td>Mean of the normal distribution
41 % <tr><td>sigma<td>Standard deviation of the normal distribution
42 % <tr><td>method<td>Optional: 'johnson' (default), 'arnold', or 'corrected'
43 % </table>
44 %
45 % @par Returns:
46 % <table>
47 % <tr><th>Name<th>Description
48 % <tr><td>Xmax<td>Approximate expected maximum E[Y_K]
49 % <tr><td>Vmax<td>Approximate variance of maximum Var[Y_K]
50 % </table>
51 %
52 % @par Reference:
53 % A. Thomasian, "Analysis of Fork/Join and Related Queueing Systems",
54 % ACM Computing Surveys, Vol. 47, No. 2, Article 17, July 2014.
55 % Eq. (45) on page 17:23.
56 %
57 % N.L. Johnson, S. Kotz, N. Balakrishnan, "Continuous Univariate
58 % Distributions", Vol. 2, Wiley, 1995.
59%}
60function [Xmax, Vmax] = fj_xmax_normal(K, mu, sigma, method)
61
62if nargin < 4
63 method = 'johnson';
64end
65
66if K < 2
67 line_error(mfilename, 'K must be at least 2 for normal approximation. Got K=%d.', K);
68end
69
70if sigma < 0
71 line_error(mfilename, 'Standard deviation sigma must be non-negative.');
72end
73
74% Euler-Mascheroni constant
75gamma_em = 0.5772156649015329;
76
77% Common term: sqrt(2*ln(K))
78sqrt_2lnK = sqrt(2 * log(K));
79
80switch lower(method)
81 case 'arnold'
82 % Simple approximation: E[Y_K] ≈ μ + σ * sqrt(2*ln(K))
83 GK = sqrt_2lnK;
84 Xmax = mu + sigma * GK;
85
86 case 'johnson'
87 % Johnson et al. approximation (Eq. 45)
88 % E[Y_K] ≈ μ + σ * [sqrt(2*ln(K)) - (ln(ln(K)) - ln(4π) + 2γ) / (2*sqrt(2*ln(K)))]
89 correction = (log(log(K)) - log(4 * pi) + 2 * gamma_em) / (2 * sqrt_2lnK);
90 GK = sqrt_2lnK - correction;
91 Xmax = mu + sigma * GK;
92
93 case 'corrected'
94 % Johnson with Petzold bias correction
95 correction = (log(log(K)) - log(4 * pi) + 2 * gamma_em) / (2 * sqrt_2lnK);
96 GK = sqrt_2lnK - correction;
97 % Subtract bias: δ(K) = 0.1727 * K^(-0.2750)
98 delta_K = 0.1727 * K^(-0.2750);
99 GK = GK - delta_K;
100 Xmax = mu + sigma * GK;
101
102 otherwise
103 line_error(mfilename, 'Unknown method: %s. Valid: johnson, arnold, corrected.', method);
104end
105
106% Compute variance if requested
107if nargout > 1
108 % Var[Y_K] ≈ 1.64492 * σ^2 / (2*ln(K))
109 Vmax = 1.64492 * sigma^2 / (2 * log(K));
110end
111
112end