LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
trace_scv.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_SCV_H
6
#define LINE_API_TRACE_TRACE_SCV_H
7
8
/**
9
* @file
10
* @ingroup api_trace
11
* Squared coefficient of variation of a trace, var/mean^2.
12
*
13
* Templated port of matlab/lib/kpctoolbox/trace/trace_scv.m, cross-checked
14
* against `jar/src/main/java/jline/api/trace/Trace_var.java#trace_scv`. The
15
* expression is the same; the two differ only through the variance
16
* denominator, see trace_var.h.
17
*
18
* ARITHMETIC: a ratio of sample moments, exact in Rational.
19
*/
20
21
#include <vector>
22
23
#include "
line/api/trace/trace_mean.h
"
24
#include "
line/api/trace/trace_types.h
"
25
#include "
line/api/trace/trace_var.h
"
26
#include "
line/num/number.h
"
27
#include "
line/util/error.h
"
28
29
namespace
line
{
30
namespace
trace
{
31
32
/**
33
* @brief Squared coefficient of variation of a trace, var/mean^2.
34
*
35
* @param S the trace
36
* @param unbiased variance denominator, see trace_var
37
*/
38
template
<
class
T>
39
T
trace_scv
(
const
std::vector<T>& S,
bool
unbiased =
true
) {
40
const
T mu =
trace_mean
(S);
41
if
(mu ==
num_traits<T>::from_int
(0))
throw
NumericError
(
"trace_scv: the trace has zero mean"
);
42
return
trace_var
(S, unbiased) / (mu * mu);
43
}
44
45
}
// namespace trace
46
}
// namespace line
47
48
#endif
// LINE_API_TRACE_TRACE_SCV_H
line::NumericError::NumericError
NumericError(const std::string &what)
Definition
error.h:45
error.h
The exception types the port throws.
line::trace
Definition
autocov.h:38
line::trace::trace_mean
T trace_mean(const std::vector< T > &S)
(1/n) sum_i S(i).
Definition
trace_mean.h:31
line::trace::trace_var
T trace_var(const std::vector< T > &S, bool unbiased=true)
Sample variance of a trace.
Definition
trace_var.h:45
line::trace::trace_scv
T trace_scv(const std::vector< T > &S, bool unbiased=true)
Squared coefficient of variation of a trace, var/mean^2.
Definition
trace_scv.h:39
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
trace_mean.h
Sample mean of a trace.
trace_types.h
Shared declarations for the empirical trace statistics domain.
trace_var.h
Sample variance of a trace.
include
line
api
trace
trace_scv.h
Generated by
1.18.0