1function [meanAoI, lstAoI, peakAoI] = aoi_fcfs_gim1(Y_lst, mu, E_Y, E_Y2)
2%AOI_FCFS_GIM1 Mean AoI and LST
for GI/M/1 FCFS queue
4% [meanAoI, lstAoI, peakAoI] = aoi_fcfs_gim1(Y_lst, mu, E_Y, E_Y2)
6% Computes
the Age of Information metrics
for a GI/M/1 queue with
7% First-Come First-Served (FCFS) discipline.
9% GI/M/1: General independent arrivals, exponential service with rate mu.
12% Y_lst (function_handle): LST of interarrival time, @(s) -> complex
13% mu (double): Service rate (exponential service)
14% E_Y (double): Mean interarrival time (first moment)
15% E_Y2 (double): Second moment of interarrival time
18% meanAoI (double): Mean (average) Age of Information
19% lstAoI (function_handle): LST of AoI distribution
20% peakAoI (double): Mean Peak Age of Information
22% Formulas (from Inoue et al., IEEE Trans. IT, 2019, Theorem 3):
23% The key parameter sigma
is the unique root in (0,1) of:
24% Y*(mu - mu*sigma) = sigma
26% LST of AoI: A*(s) = (mu*sigma_s) / (s + mu - mu*sigma_s) * D*(s)
27% where sigma_s solves Y*(s + mu - mu*sigma_s) = sigma_s
28% and D*(s)
is the LST of system delay.
31% Y. Inoue, H. Masuyama, T. Takine, T. Tanaka,
"A General Formula for
32% the Stationary Distribution of the Age of Information and Its
33% Application to Single-Server Queues," IEEE Trans. Information Theory,
34% vol. 65, no. 12, pp. 8305-8324, 2019.
36% See also: aoi_fcfs_mm1, aoi_fcfs_mgi1, aoi_fcfs_dm1
38% Copyright (c) 2012-2026, Imperial College London
43 line_error(mfilename,
'Service rate mu must be positive');
46 line_error(mfilename,
'Mean interarrival time E_Y must be positive');
49 line_error(mfilename,
'Second moment E_Y2 must be >= E_Y^2');
58 line_error(mfilename,
'System unstable: rho = 1/(E_Y*mu) = %.4f >= 1', rho);
61% Find sigma: unique root in (0,1) of Y*(mu - mu*sigma) = sigma
62% This
is the probability an arriving customer finds
the server busy
63sigma_func = @(sig) Y_lst(mu - mu * sig) - sig;
65% Use fzero to find
the root
67 sigma = fzero(sigma_func, [0.001, 0.999]);
69 % Fallback: use fixed-point iteration
72 sigma_new = Y_lst(mu - mu * sigma);
73 if abs(sigma_new - sigma) < 1e-10
80% Mean system delay for GI/M/1
81% E[D] = 1 / (mu * (1 - sigma))
82E_D = 1 / (mu * (1 - sigma));
84% Mean AoI for GI/M/1 FCFS (exact)
85% The stationary system time
is exp(eta) with eta = mu*(1-sigma) and
is
86% independent of
the next interarrival, so E[Y*W] = -Y*'(eta)/eta and
87% E[A] = lambda*E[Y^2]/2 + 1/mu + lambda*(-Y*'(eta))/eta
88% (validated against simulation)
89eta = mu * (1 - sigma);
90hstep = 1e-6 * max(1, eta);
91dYstar = (Y_lst(eta + hstep) - Y_lst(eta - hstep)) / (2 * hstep);
92meanAoI = lambda * E_Y2 / 2 + 1 / mu + lambda * (-dYstar) / eta;
95% E[Apeak] = E[Y] + E[D]
98% LST of AoI (Theorem 3)
99% This requires solving for sigma(s) at each evaluation point
100lstAoI = @(s) aoi_gim1_lst_eval(s, Y_lst, mu, sigma);
104function val = aoi_gim1_lst_eval(s, Y_lst, mu, sigma0)
105%AOI_GIM1_LST_EVAL Evaluate GI/M/1 FCFS AoI LST at point(s) s
108 % Find sigma(s): root of Y*(s + mu - mu*sigma) = sigma
109 sig_func = @(sig) Y_lst(s + mu - mu * sig) - sig;
111 sigma_s = fzero(sig_func, [0.001, 0.999]);
113 sigma_s = sigma0; % Fallback
116 % System delay LST: D*(s) = (1-sigma) * mu / (s + mu - mu*sigma_s)
117 D_s = (1 - sigma0) * mu / (s + mu - mu * sigma_s);
119 % AoI LST (Theorem 3)
120 val = (mu * sigma_s) / (s + mu - mu * sigma_s) * D_s;
123 val = zeros(size(s));
125 sig_func = @(sig) Y_lst(s(i) + mu - mu * sig) - sig;
127 sigma_s = fzero(sig_func, [0.001, 0.999]);
131 D_s = (1 - sigma0) * mu / (s(i) + mu - mu * sigma_s);
132 val(i) = (mu * sigma_s) / (s(i) + mu - mu * sigma_s) * D_s;