LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
trace_bicov.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_TRACE_BICOV_H
6
#define LINE_API_TRACE_TRACE_BICOV_H
7
8
/**
9
* @file
10
* @ingroup api_trace
11
* Bicovariance of a trace on a lag grid.
12
*
13
* Templated port of matlab/lib/kpctoolbox/trace/trace_bicov.m, cross-checked
14
* against `jar/src/main/java/jline/api/trace/Trace_var.java#trace_bicov` (same
15
* grid construction; the JAR values differ because its trace_joint drops the
16
* cumulative sum, see trace_joint.h).
17
*
18
* For every ordered pair (i,j) drawn from the grid the third-order joint
19
* moment E[X_t X_{t+i} X_{t+i+j}] is evaluated. Note that both references
20
* return the raw joint moment, not a centred cumulant, despite the name.
21
*
22
* ARITHMETIC: a vector of joint moments, exact in Rational.
23
*/
24
25
#include <cstddef>
26
#include <vector>
27
28
#include "
line/api/trace/trace_joint.h
"
29
#include "
line/api/trace/trace_types.h
"
30
#include "
line/num/number.h
"
31
#include "
line/util/error.h
"
32
33
namespace
line
{
34
namespace
trace
{
35
36
/** Return value of trace_bicov, mirroring [BiCov, BiCovLags]. */
37
template
<
class
T>
38
struct
TraceBicovResult
{
39
std::vector<T>
bicov
;
///< one moment per grid pair
40
std::vector<std::vector<int>>
lags
;
///< the [1,i,j] increment triples
41
};
42
43
/**
44
* @brief Bicovariance of a trace on a lag grid.
45
*
46
* @param S the trace
47
* @param grid the lag values swept in both positions
48
*/
49
template
<
class
T>
50
TraceBicovResult<T>
trace_bicov
(
const
std::vector<T>& S,
const
std::vector<int>& grid) {
51
detail::require_nonempty(S,
"trace_bicov"
);
52
TraceBicovResult<T>
out;
53
const
std::vector<unsigned> order(3, 1u);
54
for
(std::size_t a = 0; a < grid.size(); ++a) {
55
for
(std::size_t b = 0; b < grid.size(); ++b) {
56
std::vector<int> lag(3);
57
lag[0] = 1;
58
lag[1] = grid[a];
59
lag[2] = grid[b];
60
out.
lags
.push_back(lag);
61
out.
bicov
.push_back(
trace_joint
(S, lag, order));
62
}
63
}
64
return
out;
65
}
66
67
}
// namespace trace
68
}
// namespace line
69
70
#endif
// LINE_API_TRACE_TRACE_BICOV_H
error.h
The exception types the port throws.
line::trace
Definition
autocov.h:38
line::trace::trace_bicov
TraceBicovResult< T > trace_bicov(const std::vector< T > &S, const std::vector< int > &grid)
Bicovariance of a trace on a lag grid.
Definition
trace_bicov.h:50
line::trace::trace_joint
T trace_joint(const std::vector< T > &S, const std::vector< int > &lag, const std::vector< unsigned > &order)
Joint moments of a trace, E[X_i^{k_1} X_{i+l_2}^{k_2} ...].
Definition
trace_joint.h:53
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::trace::TraceBicovResult
Return value of trace_bicov, mirroring [BiCov, BiCovLags].
Definition
trace_bicov.h:38
line::trace::TraceBicovResult::lags
std::vector< std::vector< int > > lags
the [1,i,j] increment triples
Definition
trace_bicov.h:40
line::trace::TraceBicovResult::bicov
std::vector< T > bicov
one moment per grid pair
Definition
trace_bicov.h:39
trace_joint.h
Joint moments of a trace, E[X_i^{k_1} X_{i+l_2}^{k_2} ...].
trace_types.h
Shared declarations for the empirical trace statistics domain.
include
line
api
trace
trace_bicov.h
Generated by
1.18.0