![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Sample autocovariance sequence of a trace, lags 0 . More...
#include <cstddef>#include <vector>#include "line/api/trace/trace_mean.h"#include "line/api/trace/trace_types.h"#include "line/num/number.h"#include "line/util/error.h"Go to the source code of this file.
Namespaces | |
| namespace | line |
| Conservation laws of a layered queueing network, enumerated from its structure. | |
| namespace | line::trace |
Functions | |
| template<class T> | |
| std::vector< T > | line::trace::autocov (const std::vector< T > &S) |
| Sample autocovariance sequence of a trace, lags 0 . | |
Sample autocovariance sequence of a trace, lags 0 .
. n-2.
Templated port of matlab/lib/kpctoolbox/contrib/autocov.m, cross-checked against the private autocov() of jar/src/main/java/jline/api/trace/Trace_var.java (identical formula; the MATLAB implementation evaluates it by FFT, which is the same quantity up to rounding but is not usable in exact arithmetic, so this port evaluates the defining sum directly).
acv(p) = 1/(n-1-p) sum_{i=1}^{n-p} (S_i - Sbar)(S_{i+p} - Sbar)
The denominator is the one autocov.m actually applies, real(acv(1:M-1)) ./ (M-(1:M-1))': its k-th entry is lag k-1, divided by M-k. The lag-0 term is therefore MATLAB's var (denominator n-1), as the header of autocov.m states, and the last lag n-2 is divided by 1. (The formula in that header reads 1/(N-p) with p 1-based, which is the same thing.) This port and the JAR divided lag p by n-p until 2026-11-06 (BUG-113), which made the lag-0 term the population variance and every trace_acf, trace_gamma and trace_summary value differ from MATLAB's.
ARITHMETIC: sums, products and divisions, exact in Rational.
Definition in file autocov.h.