1classdef MarkedMAP < MarkovModulated
2 % Markov Modulated Arrival Process
4 % Copyright (c) 2012-2026, Imperial College London
9 function self = MarkedMAP(D,K)
10 % SELF = MarkedMAP(D,K)
12 % LINE uses
the M3A representation format
13 % D={D0, D1, D11, D12, D13, ..., D1K}
14 % K
is the number of marking types
16 self@MarkovModulated(
'MarkedMAP',K+2);
19 setParam(self, 1,
'D0', D{1});
20 setParam(self, 2,
'D1', cellsum({D{2:end}}));
22 setParam(self, 2+k, sprintf(
'D1%d',k), D{1+k});
24 elseif K == length(D)-2
25 setParam(self, 1,
'D0', D{1});
26 setParam(self, 2,
'D1', D{2});
28 setParam(self, 2+k, sprintf(
'D1%d',k), D{2+k});
31 line_error(mfilename,
'Inconsistency between the number of classes and the number of supplied D matrices.')
33 % Copy all K+2 params {D0, D1, D11, ..., D1K} into
the process
34 % cell (M3A layout); copying only K entries would truncate
the
35 % per-mark matrices and
break D(1,k)/getNumberOfTypes.
36 MarkedMAP = cell(1,K+2);
38 MarkedMAP{k} = self.getParam(k).paramValue;
40 self.process = MarkedMAP;
43 function Di = D(self, i, j, wantSparse)
56 line_error(mfilename,
'Invalid D matrix indexes');
60 % Return representation matrix, e.g., D0=MAP.D(0)
65 Di=self.getProcess{1+i+j};
74 Di=full(self.getProcess{1+i+j});
79 function meant = evalMeanT(self, t)
80 % MEANT = EVALMEANT(SELF,T)
82 meant = self.toMAP.evalMeanT(t);
85 function vart = evalVarT(self, t)
86 % VART = EVALVART(SELF,T)
88 % Evaluate
the variance-time curve at timescale t
89 vart = self.toMAP.evalVarT(t);
92 function acf = evalACFT(self, lags, timescale)
93 % ACF = EVALACFT(self, lags)
95 % Evaluate
the autocorrelation in counts at timescale t
97 acf = self.toMAP.evalACFT(lags, timescale);
100 % inter-arrival time properties
101 function mean = getMean(self)
104 mean = self.toMAP.getMean;
107 function scv = getSCV(self)
110 scv = self.toMAP.getSCV;
113 % inter-arrival time properties for each marking type
114 function mean = getMarkedMeans(self)
115 % MEAN = GETMARKEDMEANS()
117 mean = 1 ./ mmap_lambda(self.D);
120 function acf = getACF(self, lags)
121 % ACF = GETACF(self, lags)
123 acf = self.toMAP.getACF(lags);
126 function
map = toMAP(self)
127 map = MAP(self.D(0), self.D(1));
130 function maps = toMAPs(self, types)
132 types = 1:self.getNumberOfTypes;
137 Df = Df + (self.D(1) - self.D(1,k));
138 maps{end+1} = MAP(Df, self.D(1,k));
142 function [gamma2, gamma] = getACFDecay(self)
143 % [gamma2, gamma] = GETACFDECAY(self)
145 % gamma2: asymptotic decay rate of acf
146 % gamma: interpolated decay rate of acf
148 [gamma2, gamma] = self.toMAP.getACFDecay();
151 function
id = getIDC(self, t) % index of dispersion
for counts
152 % ID = GETIDC() % INDEX OF DISPERSION
154 id = self.toMAP.getIDC;
156 id = self.toMAP.getIDC(t);
160 function
id = getMarkedIDC(self, t) % asymptotic index of dispersion
for counts
for each type
161 % ID = GETMARKEDIDC() % ASYMPTOTIC INDEX OF DISPERSION
163 id = mmap_count_idc(self.getProcess, GlobalConstants.Immediate);
165 id = mmap_count_idc(self.getProcess, t);
169 function lam = getRate(self)
172 lam = self.toMAP.getRate;
175 function n = getNumberOfPhases(self)
176 % N = GETNUMBEROFMAPASES()
177 D0 = self.getParam(1).paramValue;
181 function mu = getMu(self)
183 % Aggregate departure rate from each state
184 mu = sum(self.D(1),2); % sum D1 rows / diag -D0
187 function phi = getPhi(self)
189 % Return
the exit vector of
the underlying MAP
190 phi = sum(self.D(1),2) ./ diag(-self.D(0)); % sum D1 rows / diag -D0
193 function K = getNumberOfTypes(self)
194 % K = GETNUMBEROFTYPES()
195 % Number of marking types
197 K = length(self.D)-2;
200 function MMAPr = toTimeReversed(self)
201 MMAPr = MarkedMAP(mmap_timereverse(self.D), self.getNumberOfTypes);
204 function [X,C] = sample(self, n)
206 if nargin<2 %~exist('n','var'),
209 MarkedMAP = self.getProcess;
210 if mmap_isfeasible(MarkedMAP)
211 [X,C] = mmap_sample(MarkedMAP,n);
213 line_error(mfilename,'This process
is infeasible (negative rates).');
221 function mmap = fit(trace, markings, order)
222 % M3PP = FIT(TRACE, ORDER)
223 T = m3afit_init(trace,markings);
224 mmap = m3afit_auto(T,'NumStates',order);
228 function mmap = rand(order, nclasses)
229 % MarkedMAP = RAND(ORDER,NCLASSES)
231 % Generate random MarkedMAP using uniform random numbers
235 mmap = MarkedMAP(mmap_rand(order,nclasses),nclasses);