LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
mtrace_moment.m
1function [M] = mtrace_moment(T,A,ORDERS,AFTER,NORM)
2% Computes the empirical class-dependent moments of a multi-class trace.
3% T: vector of inter-arrival times
4% A: vector of class labels
5% ORDERS: vector with the orders of the moments to compute
6% AFTER: 0 to compute moments of Horvath variables
7% 1 to compute moments of Bucholz variables
8% NORM: 0 to not normalize, M_i = sum M_{i,c}
9% 1 to normalize, M_i = sum M_{i,c} * g_c
10% where M_i is the class independent moment of order i
11% M_{i,c} is the class c moment of order i
12% g_c is the fraction of arrivals of class c
13
14if nargin == 3
15 AFTER = 0;
16end
17
18if nargin <= 4
19 NORM = 0;
20end
21
22MARKS = unique(A);
23
24C = length(MARKS);
25
26M = zeros(C,length(ORDERS));
27
28for j = 1:length(ORDERS)
29 k = ORDERS(j);
30 for c = 1:C
31 if AFTER
32 M(c,j) = mean(T(2:end).^k .* (A(1:(end-1)) == MARKS(c)));
33 else
34 M(c,j) = mean(T.^k .* (A==MARKS(c)));
35 end
36 if NORM
37 if AFTER
38 M(c,j) = M(c,j) * length(T-1)/sum(A(1:(end-1))==MARKS(c));
39 else
40 M(c,j) = M(c,j) * length(T)/sum(A==MARKS(c));
41 end
42 end
43 end
44end
45
46end