LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
trace_var.h File Reference

Sample variance of a trace. More...

#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"
Include dependency graph for trace_var.h:

Go to the source code of this file.

Namespaces

namespace  line
namespace  line::trace

Functions

template<class T>
line::trace::trace_var (const std::vector< T > &S, bool unbiased=true)
 Sample variance of a trace.

Detailed Description

Sample variance of a trace.

Templated port of matlab/lib/kpctoolbox/trace/trace_var.m (which is MATLAB's var, denominator n-1), cross-checked against jar/src/main/java/jline/api/trace/Trace_var.java.

DIVERGENCE, MATLAB vs JAR: the JAR computes E[X^2] - E[X]^2, i.e. the POPULATION variance with denominator n, while MATLAB's var uses the unbiased denominator n-1. The two differ by the factor n/(n-1), which is not negligible on the short traces used in tests and propagates into trace_scv, trace_idi and trace_idc. MATLAB is the reference, so unbiased defaults to true; pass false to reproduce the JAR.

ARITHMETIC: sums and one division, exact in Rational.

Definition in file trace_var.h.