1function [AoI_cdf, PAoI_cdf] = getCdfAoI(self, t_values)
2%GETCDFAOI Get CDF of Age of Information
4% [AoI_cdf, PAoI_cdf] = GETCDFAOI(t_values)
6% Returns the cumulative distribution function (CDF) of Age of Information
7% and Peak AoI computed
using matrix exponential representations.
9% The CDF
is computed
using the formula:
10% F(t) = 1 - g * expm(A*t) * h
12% where g, A, h are the matrix exponential parameters from the aoi-fluid solver.
15% self: SolverFLD instance
16% t_values (optional): Vector of time values at which to evaluate CDF
17% If not provided, uses automatic range based on mean
20% AoI_cdf: [n x 2] matrix with [CDF_values, t_values] for AoI
21% PAoI_cdf: [n x 2] matrix with [CDF_values, t_values] for Peak AoI
24% model = Network(
'AoI_Example');
25% % ... model setup ...
26% solver = SolverFLD(model,
'method',
'mfq');
29% % Get CDF at automatic time points
30% [AoI_cdf, PAoI_cdf] = solver.getCdfAoI();
34% plot(AoI_cdf(:,2), AoI_cdf(:,1),
'b-',
'LineWidth', 2);
36% plot(PAoI_cdf(:,2), PAoI_cdf(:,1),
'r--',
'LineWidth', 2);
39% legend(
'AoI',
'Peak AoI');
41% % Get CDF at specific time points
42% t = linspace(0, 10, 100);
43% [AoI_cdf, PAoI_cdf] = solver.getCdfAoI(t);
45% See also: getAvgAoI, solver_mfq_aoi, aoi_is_aoi
47% Copyright (c) 2012-2026, Imperial College London
50% Ensure solver has been run
51if isempty(self.result)
59% Check if AoI results are available
60if ~isfield(self.result, 'solverSpecific') || ...
61 ~isfield(self.result.solverSpecific, 'aoiResults') || ...
62 isempty(self.result.solverSpecific.aoiResults)
63 line_warning(mfilename, 'No AoI results available. Ensure model has valid AoI topology and use method=''mfq''.');
67aoiResults = self.result.solverSpecific.aoiResults;
69% Check if matrix exponential parameters are available
70if isempty(aoiResults.AoI_A) || isempty(aoiResults.AoI_g) || isempty(aoiResults.AoI_h)
71 line_warning(mfilename, 'Matrix exponential parameters not available for AoI CDF computation.');
75% Generate time values if not provided
76if nargin < 2 || isempty(t_values)
77 % Use automatic range based on mean AoI
78 mean_aoi = aoiResults.AoI_mean;
79 if isnan(mean_aoi) || mean_aoi <= 0
80 mean_aoi = 1; % Default if mean
is invalid
82 % Range from 0 to 5 times the mean (covers most of the distribution)
84 t_values = linspace(0, t_max, 200);
87t_values = t_values(:); % Ensure column vector
90% Extract matrix exponential parameters for AoI
91AoI_g = aoiResults.AoI_g;
92AoI_A = aoiResults.AoI_A;
93AoI_h = aoiResults.AoI_h;
95% Compute AoI CDF: F(t) = 1 - g * expm(A*t) * h
102 % Compute matrix exponential
103 expAt = expm(AoI_A * t);
104 ccdf = AoI_g * expAt * AoI_h;
105 AoI_F(i) = max(0, min(1, 1 - ccdf));
109AoI_cdf = [AoI_F, t_values];
111% Extract matrix exponential parameters for Peak AoI
112PAoI_g = aoiResults.PAoI_g;
113PAoI_A = aoiResults.PAoI_A;
114PAoI_h = aoiResults.PAoI_h;
116% Compute Peak AoI CDF: F(t) = 1 - g * expm(A*t) * h
123 % Compute matrix exponential
124 expAt = expm(PAoI_A * t);
125 ccdf = PAoI_g * expAt * PAoI_h;
126 PAoI_F(i) = max(0, min(1, 1 - ccdf));
130PAoI_cdf = [PAoI_F, t_values];