1function [meanAoI, lstAoI, peakAoI] = aoi_fcfs_mgi1(lambda, H_lst, E_H, E_H2)
2%AOI_FCFS_MGI1 Mean AoI and LST
for M/GI/1 FCFS queue
4% [meanAoI, lstAoI, peakAoI] = aoi_fcfs_mgi1(lambda, H_lst, E_H, E_H2)
6% Computes
the Age of Information metrics
for an M/GI/1 queue with
7% First-Come First-Served (FCFS) discipline.
9% M/GI/1: Poisson arrivals with rate lambda, general independent service.
12% lambda (
double): Arrival rate (Poisson arrivals)
13% H_lst (function_handle): LST of service time, @(s) -> complex
14% E_H (double): Mean service time (first moment)
15% E_H2 (double): Second moment of service 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 2):
23% LST of AoI: A*(s) = (lambda * H*(s)) / (s + lambda - lambda*H*(s)) * W*(s)
24% where W*(s)
is the LST of waiting time (Pollaczek-Khinchine).
26% Mean AoI (Proposition 1):
27% E[A] = E[H] + E[T] + (1-2*rho)/lambda - d/ds T*(s)|_{s=lambda} (exact)
30% Y. Inoue, H. Masuyama, T. Takine, T. Tanaka,
"A General Formula for
31% the Stationary Distribution of the Age of Information and Its
32% Application to Single-Server Queues," IEEE Trans. Information Theory,
33% vol. 65, no. 12, pp. 8305-8324, 2019.
35% See also: aoi_fcfs_mm1, aoi_fcfs_gim1, aoi_lst_exp, aoi_lst_erlang
37% Copyright (c) 2012-2026, Imperial College London
42 line_error(mfilename,
'Arrival rate lambda must be positive');
45 line_error(mfilename,
'Mean service time E_H must be positive');
48 line_error(mfilename,
'Second moment E_H2 must be >= E_H^2');
56 line_error(mfilename,
'System unstable: rho = lambda*E_H = %.4f >= 1', rho);
59% Mean interarrival time
62% Mean waiting time (Pollaczek-Khinchine formula)
63% E[W] = lambda * E[H^2] / (2 * (1 - rho))
64E_W = lambda * E_H2 / (2 * (1 - rho));
66% Mean system time (sojourn time)
69% Mean AoI
for M/GI/1 FCFS (exact)
70% E[A] = E[H] + E[T] + (1-2*rho)/lambda - d/ds T*(s)|_{s=lambda}
71% where T*(s) = H*(s)*W*(s)
is the system-time LST (Pollaczek-Khinchine).
72% The derivative term captures
the interarrival/system-time correlation
73% E[Y*W] = E[Y(T
'-Y)^+]; validated against simulation.
74Tstar = @(s) H_lst(s) .* ((1 - rho) .* s ./ (s - lambda + lambda .* H_lst(s)));
75hstep = 1e-6 * max(1, lambda);
76dTstar = (Tstar(lambda + hstep) - Tstar(lambda - hstep)) / (2 * hstep);
77meanAoI = E_H + E_T + (1 - 2 * rho) / lambda - dTstar;
80% E[Apeak] = E[T] + E[Y]
83% LST of AoI (Theorem 2)
84% A*(s) = (lambda * H*(s)) / (s + lambda - lambda*H*(s)) * W*(s)
85% where W*(s) is the Pollaczek-Khinchine LST:
86% W*(s) = (1-rho) * s / (s - lambda + lambda*H*(s))
88lstAoI = @(s) aoi_mgi1_lst_eval(s, lambda, H_lst, rho);
92function val = aoi_mgi1_lst_eval(s, lambda, H_lst, rho)
93%AOI_MGI1_LST_EVAL Evaluate M/GI/1 FCFS AoI LST at point(s) s
97 % Pollaczek-Khinchine LST for waiting time
98 W_s = (1 - rho) * s / (s - lambda + lambda * H_s);
100 val = (lambda * H_s) / (s + lambda - lambda * H_s) * W_s;
103 val = zeros(size(s));
106 W_s = (1 - rho) * s(i) / (s(i) - lambda + lambda * H_s);
107 val(i) = (lambda * H_s) / (s(i) + lambda - lambda * H_s) * W_s;