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 MarkedMAP = cell(1,K-1);
35 MarkedMAP{k} = self.getParam(k).paramValue;
37 self.process = MarkedMAP;
40 function Di = D(self, i, j, wantSparse)
53 line_error(mfilename,
'Invalid D matrix indexes');
57 % Return representation matrix, e.g., D0=MAP.D(0)
62 Di=self.getProcess{1+i+j};
71 Di=full(self.getProcess{1+i+j});
76 function meant = evalMeanT(self, t)
77 % MEANT = EVALMEANT(SELF,T)
79 meant = self.toMAP.evalMeanT(t);
82 function vart = evalVarT(self, t)
83 % VART = EVALVART(SELF,T)
85 % Evaluate the variance-time curve at timescale t
86 vart = self.toMAP.evalVarT(t);
89 function acf = evalACFT(self, lags, timescale)
90 % ACF = EVALACFT(self, lags)
92 % Evaluate the autocorrelation in counts at timescale t
94 acf = self.toMAP.evalACFT(lags, timescale);
97 % inter-arrival time properties
98 function mean = getMean(self)
101 mean = self.toMAP.getMean;
104 function scv = getSCV(self)
107 scv = self.toMAP.scv;
110 % inter-arrival time properties for each marking type
111 function mean = getMarkedMeans(self)
112 % MEAN = GETMARKEDMEANS()
114 mean = 1 ./ mmap_lambda(self.D);
117 function acf = getACF(self, lags)
118 % ACF = GETACF(self, lags)
120 acf = self.toMAP.getACF(lags);
123 function
map = toMAP(self)
124 map = MAP(self.D(0), self.D(1));
127 function maps = toMAPs(self, types)
129 types = 1:self.getNumberOfTypes;
134 Df = Df + (self.D(1) - self.D(1,k));
135 maps{end+1} = MAP(Df, self.D(1,k));
139 function [gamma2, gamma] = getACFDecay(self)
140 % [gamma2, gamma] = GETACFDECAY(self)
142 % gamma2: asymptotic decay rate of acf
143 % gamma: interpolated decay rate of acf
145 [gamma2, gamma] = self.toMAP.getACFDecay();
148 function
id = getIDC(self, t) % index of dispersion
for counts
149 % ID = GETIDC() % INDEX OF DISPERSION
151 id = self.toMAP.getIDC;
153 id = self.toMAP.getIDC(t);
157 function
id = getMarkedIDC(self, t) % asymptotic index of dispersion
for counts
for each type
158 % ID = GETMARKEDIDC() % ASYMPTOTIC INDEX OF DISPERSION
160 id = mmap_count_idc(self.getProcess, GlobalConstants.Immediate);
162 id = mmap_count_idc(self.getProcess, t);
166 function lam = getRate(self)
169 lam = self.toMAP.getRate;
172 function n = getNumberOfPhases(self)
173 % N = GETNUMBEROFMAPASES()
174 D0 = self.getParam(1).paramValue;
178 function mu = getMu(self)
180 % Aggregate departure rate from each state
181 mu = sum(self.D(1),2); % sum D1 rows / diag -D0
184 function phi = getPhi(self)
186 % Return the exit vector of the underlying MAP
187 phi = sum(self.D(1),2) ./ diag(-self.D(0)); % sum D1 rows / diag -D0
190 function K = getNumberOfTypes(self)
191 % K = GETNUMBEROFTYPES()
192 % Number of marking types
194 K = length(self.D)-2;
197 function MMAPr = toTimeReversed(self)
198 MMAPr = MarkedMAP(mmap_timereverse(self.D), self.getNumberOfTypes);
201 function [X,C] = sample(self, n)
203 if nargin<2 %~exist('n','var'),
206 MarkedMAP = self.getProcess;
207 if mmap_isfeasible(MarkedMAP)
208 [X,C] = mmap_sample(MarkedMAP,n);
210 line_error(mfilename,'This process
is infeasible (negative rates).');
218 function mmap = fit(trace, markings, order)
219 % M3PP = FIT(TRACE, ORDER)
220 T = m3afit_init(trace,markings);
221 mmap = m3afit_auto(T,'NumStates',order);
225 function mmap = rand(order, nclasses)
226 % MarkedMAP = RAND(ORDER,NCLASSES)
228 % Generate random MarkedMAP using uniform random numbers
232 mmap = MarkedMAP(mmap_rand(order,nclasses),nclasses);