LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fj_gk_bound.m
1%{ @file fj_gk_bound.m
2 % @brief Compute G(K) factors for expected maximum approximation
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Compute G(K) factors for expected maximum approximation
9 %
10 % @details
11 % Computes the G(K) factor used in the approximation:
12 % X_K^max ≈ mu_X + sigma_X * G(K)
13 %
14 % For standardized distributions (mean=0, variance=1), G(K) = X_K^max.
15 %
16 % Available G(K) formulas:
17 % - Exponential: G(K) = H_K - 1
18 % - Uniform: G(K) = sqrt(3) * (K-1) / (K+1)
19 % - EVD: G(K) = sqrt(6) * ln(K) / pi
20 % - Upper bound: G(K) <= (K-1) / sqrt(2K-1) (tight bound from David [1970])
21 %
22 % @par Syntax:
23 % @code
24 % GK = fj_gk_bound(K) % Returns struct with all
25 % GK = fj_gk_bound(K, 'exp') % Exponential G(K)
26 % GK = fj_gk_bound(K, 'uniform') % Uniform G(K)
27 % GK = fj_gk_bound(K, 'evd') % EVD G(K)
28 % GK = fj_gk_bound(K, 'bound') % Upper bound
29 % @endcode
30 %
31 % @par Parameters:
32 % <table>
33 % <tr><th>Name<th>Description
34 % <tr><td>K<td>Number of random variables (positive integer)
35 % <tr><td>type<td>Optional: 'exp', 'uniform', 'evd', 'bound', or 'all' (default)
36 % </table>
37 %
38 % @par Returns:
39 % <table>
40 % <tr><th>Name<th>Description
41 % <tr><td>GK<td>G(K) value(s) - scalar or struct depending on type
42 % </table>
43 %
44 % @par Reference:
45 % A. Thomasian, "Analysis of Fork/Join and Related Queueing Systems",
46 % ACM Computing Surveys, Vol. 47, No. 2, Article 17, July 2014.
47 % Eq. (22) and (23) on page 17:16.
48 %
49 % Original: H.A. David, "Order Statistics", Wiley, 1970.
50%}
51function GK = fj_gk_bound(K, type)
52
53if nargin < 2
54 type = 'all';
55end
56
57if K < 1
58 line_error(mfilename, 'K must be a positive integer. Got K=%d.', K);
59end
60
61switch lower(type)
62 case 'exp'
63 % Exponential distribution: G(K) = H_K - 1
64 GK = fj_harmonic(K) - 1;
65
66 case 'uniform'
67 % Uniform distribution: G(K) = sqrt(3) * (K-1) / (K+1)
68 GK = sqrt(3) * (K - 1) / (K + 1);
69
70 case 'evd'
71 % Extreme Value Distribution: G(K) = sqrt(6) * ln(K) / pi
72 GK = sqrt(6) * log(K) / pi;
73
74 case 'bound'
75 % Upper bound for any distribution: G(K) <= (K-1) / sqrt(2K-1)
76 GK = (K - 1) / sqrt(2 * K - 1);
77
78 case 'all'
79 % Return struct with all G(K) values
80 GK = struct();
81 GK.K = K;
82 GK.exponential = fj_harmonic(K) - 1;
83 GK.uniform = sqrt(3) * (K - 1) / (K + 1);
84 GK.evd = sqrt(6) * log(K) / pi;
85 GK.upper_bound = (K - 1) / sqrt(2 * K - 1);
86
87 otherwise
88 line_error(mfilename, 'Unknown type: %s. Valid: exp, uniform, evd, bound, all.', type);
89end
90
91end