LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
moment_tail.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_MOMENT_MOMENT_TAIL_H
6
#define LINE_API_MOMENT_MOMENT_TAIL_H
7
8
/**
9
* @file
10
* @ingroup api_moment
11
* Binomial moments from tail moments and the inverse.
12
*
13
* Templated port of matlab/src/api/moment/moment_binomial_from_tail.m and
14
* moment_tail_from_binomial.m. These are the only edges of the house of moments
15
* whose table is UPPER triangular, so both directions read the WHOLE remaining
16
* sequence: b_i depends on t_i,...,t_n. Truncating the input therefore
17
* truncates the information, not just the output order.
18
*
19
* Reference:
20
* A. Heindl and A. van de Liefvoort. Moment conversions for discrete
21
* distributions. PMCCS, 2003.
22
*/
23
24
#include <vector>
25
26
#include "
line/api/moment/moment_housematrix.h
"
27
#include "
line/num/number.h
"
28
#include "
line/util/error.h
"
29
#include "
line/util/matrix.h
"
30
31
namespace
line
{
32
namespace
moment
{
33
34
/** b_i = sum_{k>=i} C(k-1,i-1) t_k. */
35
template
<
class
T>
36
std::vector<T>
moment_binomial_from_tail
(
const
std::vector<T>& t) {
37
if
(t.empty())
throw
InputError
(
"moment_binomial_from_tail: t must be nonempty"
);
38
return
moment_apply_full<T>
(
39
moment_housematrix<T>
(
MomentEdge::BinomialFromTail
,
static_cast<
int
>
(t.size()) - 1), t);
40
}
41
42
/** t_i = sum_{k>=i} (-1)^(k-i) C(k-1,i-1) b_k. */
43
template
<
class
T>
44
std::vector<T>
moment_tail_from_binomial
(
const
std::vector<T>& b) {
45
if
(b.empty())
throw
InputError
(
"moment_tail_from_binomial: b must be nonempty"
);
46
return
moment_apply_full<T>
(
47
moment_housematrix<T>
(
MomentEdge::TailFromBinomial
,
static_cast<
int
>
(b.size()) - 1), b);
48
}
49
50
}
// namespace moment
51
}
// namespace line
52
53
#endif
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
matrix.h
Dense matrix and non-owning view.
moment_housematrix.h
Conversion matrix of one edge of the house of moments.
line::moment
Definition
moment_apply.h:28
line::moment::moment_housematrix
Matrix< T > moment_housematrix(MomentEdge edge, int n)
(n+1)x(n+1) conversion table of the given edge.
Definition
moment_housematrix.h:82
line::moment::moment_tail_from_binomial
std::vector< T > moment_tail_from_binomial(const std::vector< T > &b)
ti = sum{k>=i} (-1)^(k-i) C(k-1,i-1) b_k.
Definition
moment_tail.h:44
line::moment::moment_apply_full
std::vector< T > moment_apply_full(const Matrix< T > &A, const std::vector< T > &v)
Full matrix-vector product, needed because the tail edges are upper triangular.
Definition
moment_housematrix.h:155
line::moment::moment_binomial_from_tail
std::vector< T > moment_binomial_from_tail(const std::vector< T > &t)
bi = sum{k>=i} C(k-1,i-1) t_k.
Definition
moment_tail.h:36
line::moment::MomentEdge::BinomialFromTail
@ BinomialFromTail
Definition
moment_housematrix.h:57
line::moment::MomentEdge::TailFromBinomial
@ TailFromBinomial
Definition
moment_housematrix.h:58
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
include
line
api
moment
moment_tail.h
Generated by
1.18.0