LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
mtrace_backward_moment.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012-2026, QORE Lab, Imperial College London
3
* All rights reserved.
4
*/
5
#ifndef LINE_API_TRACE_MTRACE_BACKWARD_MOMENT_H
6
#define LINE_API_TRACE_MTRACE_BACKWARD_MOMENT_H
7
8
/**
9
* @file
10
* @ingroup api_trace
11
* Backward moments of a marked trace: the moments of the inter-arrival time
12
* that PRECEDES an event of each class,
13
*
14
* B(c,k) = (1/N) sum_{i: A_i = c} T_i^k,
15
*
16
* normalized by N/count_c when norm is set, so that M_k = sum_c B(c,k) p_c.
17
*
18
* Templated port of matlab/lib/m3a/m3a/mtrace/mtrace_backward_moment.m. In
19
* MATLAB this is mtrace_moment(T,A,orders,0,NORM) with NORM defaulting to on,
20
* since T_i is by construction the interval ending at event i.
21
*
22
* DIVERGENCE, MATLAB vs JAR: Mtrace_backward_moment.java computes a
23
* DIFFERENT statistic. It accumulates absolute arrival epochs and, for each
24
* class, forms the intervals between CONSECUTIVE EVENTS OF THAT SAME CLASS
25
* (the class-c recurrence times, with the first one measured from the origin)
26
* and returns their raw moments, indexed by the raw label 0..max(A) rather
27
* than by the position in unique(A). That is the per-class inter-event time,
28
* i.e. what mtrace_split feeds to a single-class estimator, not the backward
29
* moment of the marked process, and it agrees with MATLAB only when every
30
* event belongs to the same class. Its second entry point,
31
* mtrace_backward_moment_conditional, has no MATLAB counterpart at all and is
32
* not ported. MATLAB is the reference here.
33
*
34
* ARITHMETIC: sums of integer powers and a division, exact in Rational.
35
*/
36
37
#include <vector>
38
39
#include "
line/api/trace/mtrace_moment.h
"
40
#include "
line/api/trace/trace_types.h
"
41
#include "
line/num/number.h
"
42
#include "
line/util/matrix.h
"
43
44
namespace
line
{
45
namespace
trace
{
46
47
/**
48
* @brief Backward moments of a marked trace: the moments of the inter-arrival
49
* time that PRECEDES an event of each class, B(c,k) = (1/N) sum_{i:
50
* A_i = c} T_i^k, normalized by N/count_c when norm is set, so that
51
* M_k = sum_c B(c,k) p_c.
52
*
53
* @param Tv inter-arrival times
54
* @param A class labels
55
* @param orders moment orders
56
* @param norm normalize by N/count_c (the MATLAB default)
57
*/
58
template
<
class
T>
59
Matrix<T>
mtrace_backward_moment
(
const
std::vector<T>& Tv,
const
std::vector<int>& A,
60
const
std::vector<unsigned>& orders,
bool
norm =
true
) {
61
return
mtrace_moment
(Tv, A, orders,
false
, norm);
62
}
63
64
}
// namespace trace
65
}
// namespace line
66
67
#endif
// LINE_API_TRACE_MTRACE_BACKWARD_MOMENT_H
line::Matrix
Definition
matrix.h:56
matrix.h
Dense matrix and non-owning view.
mtrace_moment.h
Empirical class-dependent moments of a marked trace.
line::trace
Definition
autocov.h:38
line::trace::mtrace_backward_moment
Matrix< T > mtrace_backward_moment(const std::vector< T > &Tv, const std::vector< int > &A, const std::vector< unsigned > &orders, bool norm=true)
Backward moments of a marked trace: the moments of the inter-arrival time that PRECEDES an event of e...
Definition
mtrace_backward_moment.h:59
line::trace::mtrace_moment
Matrix< T > mtrace_moment(const std::vector< T > &Tv, const std::vector< int > &A, const std::vector< unsigned > &orders, bool after=false, bool norm=false)
Empirical class-dependent moments of a marked trace.
Definition
mtrace_moment.h:65
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
trace_types.h
Shared declarations for the empirical trace statistics domain.
include
line
api
trace
mtrace_backward_moment.h
Generated by
1.18.0