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 (Proposition 2)
85% E[A] = E[Y] + E[D] + sigma / (mu * (1 - sigma) * (1 - sigma_prime))
86% where sigma_prime = d/ds sigma(s)|_{s=0}
88% For the mean, we can use:
89% E[A] = E[Y] + E[D] + sigma * E[Y] / (1 - sigma)
90% This
is a simplification; the exact formula involves derivatives.
92% Approximate mean AoI
using the relationship from the paper
93meanAoI = E_Y + E_D + sigma / (mu * (1 - sigma));
96% E[Apeak] = E[Y] + E[D]
99% LST of AoI (Theorem 3)
100% This
requires solving
for sigma(s) at each evaluation point
101lstAoI = @(s) aoi_gim1_lst_eval(s, Y_lst, mu, sigma);
105function val = aoi_gim1_lst_eval(s, Y_lst, mu, sigma0)
106%AOI_GIM1_LST_EVAL Evaluate GI/M/1 FCFS AoI LST at point(s) s
109 % Find sigma(s): root of Y*(s + mu - mu*sigma) = sigma
110 sig_func = @(sig) Y_lst(s + mu - mu * sig) - sig;
112 sigma_s = fzero(sig_func, [0.001, 0.999]);
114 sigma_s = sigma0; % Fallback
117 % System delay LST: D*(s) = (1-sigma) * mu / (s + mu - mu*sigma_s)
118 D_s = (1 - sigma0) * mu / (s + mu - mu * sigma_s);
120 % AoI LST (Theorem 3)
121 val = (mu * sigma_s) / (s + mu - mu * sigma_s) * D_s;
124 val = zeros(size(s));
126 sig_func = @(sig) Y_lst(s(i) + mu - mu * sig) - sig;
128 sigma_s = fzero(sig_func, [0.001, 0.999]);
132 D_s = (1 - sigma0) * mu / (s(i) + mu - mu * sigma_s);
133 val(i) = (mu * sigma_s) / (s(i) + mu - mu * sigma_s) * D_s;