1%{ @file fj_xmax_normal.m
2 % @brief Expected maximum
for normal distribution
4 % @author LINE Development Team
8 % @brief Expected maximum
for normal distribution
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].
14 % E[Y_K] ≈ μ + σ * [sqrt(2*ln(K)) - (ln(ln(K)) - ln(4π) + 2γ) / (2*sqrt(2*ln(K)))]
16 % where γ ≈ 0.5772
is the Euler-Mascheroni constant.
18 % A bias correction from Petzold [2000] can be applied:
19 % δ(K) = 0.1727 * K^(-0.2750)
21 % The variance of the maximum
is approximately:
22 % Var[Y_K] ≈ 1.64492 * σ^2 / (2*ln(K))
24 % A simpler approximation from Arnold [1980]
is also available:
25 % E[Y_K] ≈ μ + σ * sqrt(2*ln(K))
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
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'
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]
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.
57 % N.L. Johnson, S. Kotz, N. Balakrishnan,
"Continuous Univariate
58 % Distributions", Vol. 2, Wiley, 1995.
60function [Xmax, Vmax] = fj_xmax_normal(K, mu, sigma, method)
67 line_error(mfilename,
'K must be at least 2 for normal approximation. Got K=%d.', K);
71 line_error(mfilename,
'Standard deviation sigma must be non-negative.');
74% Euler-Mascheroni constant
75gamma_em = 0.5772156649015329;
77% Common term: sqrt(2*ln(K))
78sqrt_2lnK = sqrt(2 * log(K));
82 % Simple approximation: E[Y_K] ≈ μ + σ * sqrt(2*ln(K))
84 Xmax = mu + sigma * GK;
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;
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);
100 Xmax = mu + sigma * GK;
103 line_error(mfilename,
'Unknown method: %s. Valid: johnson, arnold, corrected.', method);
106% Compute variance
if requested
108 % Var[Y_K] ≈ 1.64492 * σ^2 / (2*ln(K))
109 Vmax = 1.64492 * sigma^2 / (2 * log(K));