LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
map_count_moment.m
1function [M] = map_count_moment(MAP, t, order)
2% Computes power moments of counts, at resolution t, of a MAP.
3% INPUT
4% - MAP: Markovian Arrival Process
5% - t: resolution
6% - order: orders of the moments to compute
7% OUTPUT
8% - M: power moments of counts
9
10n = size(MAP{1},1);
11theta = map_prob(MAP);
12
13if map_issym(MAP)
14 e = sym(ones(n,1));
15 M = sym(zeros(length(order),1));
16else
17 e = ones(n,1);
18 M = zeros(length(order),1);
19end
20
21if map_issym(MAP) || max(order) > 4
22 % symbolic derivative
23 z = sym('z');
24 MZ = theta*expm(MAP{1}*t+MAP{2}*exp(z)*t)*e;
25 for i = 1:length(order)
26 M(i) = subs(diff(MZ,z,order(i)),z,0);
27 end
28else
29 % numerical derivative
30 for i = 1:length(order)
31 M(i) = derivest(@(z) mgfunc(z), 0, 'deriv', order(i));
32 end
33end
34
35 function r = mgfunc(z)
36 for j=1:length(z) %derivest passes a vector
37 r(j) = theta*expm(MAP{1}*t+MAP{2}*exp(z(j))*t)*e;
38 end
39 end
40
41end