LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
trace_mean.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_MEAN_H
6
#define LINE_API_TRACE_TRACE_MEAN_H
7
8
/**
9
* @file
10
* @ingroup api_trace
11
* Sample mean of a trace.
12
*
13
* Templated port of matlab/lib/kpctoolbox/trace/trace_mean.m, cross-checked
14
* against jar/src/main/java/jline/api/trace/Trace_mean.java (identical: both
15
* are sum/n).
16
*
17
* ARITHMETIC: a sum and one division, exact in Rational.
18
*/
19
20
#include <vector>
21
22
#include "
line/api/trace/trace_types.h
"
23
#include "
line/num/number.h
"
24
#include "
line/util/error.h
"
25
26
namespace
line
{
27
namespace
trace
{
28
29
/** (1/n) sum_i S(i). */
30
template
<
class
T>
31
T
trace_mean
(
const
std::vector<T>& S) {
32
detail::require_nonempty(S,
"trace_mean"
);
33
T s =
num_traits<T>::from_int
(0);
34
for
(
const
T& v : S) s += v;
35
return
s /
num_traits<T>::from_int
(
static_cast<
long
>
(S.size()));
36
}
37
38
}
// namespace trace
39
}
// namespace line
40
41
#endif
// LINE_API_TRACE_TRACE_MEAN_H
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
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
trace_types.h
Shared declarations for the empirical trace statistics domain.
include
line
api
trace
trace_mean.h
Generated by
1.18.0