![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Autocorrelation decay rate of a trace: the gamma of the geometric model rho(k) = rho0 * gamma^k, with rho0 = (1 - 1/scv)/2 fixed by the second moment and gamma fitted by least squares on the empirical acf. More...
#include <cstddef>#include <vector>#include "line/api/trace/trace_acf.h"#include "line/api/trace/trace_mean.h"#include "line/api/trace/trace_scv.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.
Classes | |
| struct | line::trace::TraceGammaResult< T > |
| Return value of trace_gamma, mirroring [GAMMA, RHO0, RESIDUALS]. More... | |
Namespaces | |
| namespace | line |
| namespace | line::trace |
Functions | |
| template<class T> | |
| TraceGammaResult< T > | line::trace::trace_gamma (const std::vector< T > &S, long limit=1000, const std::vector< T > &grid=std::vector< T >()) |
| Autocorrelation decay rate of a trace: the gamma of the geometric model rho(k) = rho0 * gamma^k, with rho0 = (1 - 1/scv)/2 fixed by the second moment and gamma fitted by least squares on the empirical acf. | |
Autocorrelation decay rate of a trace: the gamma of the geometric model rho(k) = rho0 * gamma^k, with rho0 = (1 - 1/scv)/2 fixed by the second moment and gamma fitted by least squares on the empirical acf.
Templated port of jar/src/main/java/jline/api/trace/Trace_var.java#trace_gamma, cross-checked against matlab/lib/kpctoolbox/trace/trace_gamma.m.
DIVERGENCE, MATLAB vs JAR: MATLAB fits gamma by nonlinear regression (nlinfit with a fair robust weight, falling back to lsqcurvefit), the JAR by an exhaustive search over the ten grid points 0.990, 0.991, ..., 0.999. The JAR can therefore never report a decay rate outside that window and its resolution is 1e-3, so the two agree only when the true rate happens to sit on the grid. The grid search is what is ported, because it is the only one of the two that is deterministic and free of an optimizer dependency; the grid is exposed as a parameter so a caller can refine it.
REFERENCE DEFECT (JAR): trace_gamma builds the lags 1..min(limit, n-1) and then indexes the trace_acf result by those lags, but trace_acf silently DROPS every lag above n-2. For any trace with n <= limit+1 – with the default limit of 1000, any trace of at most 1001 samples – the returned array is one element shorter than the loop bound and the method throws ArrayIndexOutOfBoundsException. This port builds the lags as 1..min(limit, n-2) so that the residual is computed on the acf that actually exists.
ARITHMETIC: rho0 and the residual sum of squares are rational in the samples, and the grid points are raised to INTEGER lag powers, so the whole fit is a field computation; instantiated for double, Rational and Real50.
Definition in file trace_gamma.h.