5#ifndef LINE_LANG_DIST_SCALE_RATE_H
6#define LINE_LANG_DIST_SCALE_RATE_H
50 throw InputError(
"dist_scale_rate: the scaling factor must be positive");
53 "dist_scale_rate: a Prior is a set of alternative models, not one law with a time "
54 "scale; perturb the alternatives instead");
57 "dist_scale_rate: a MAPt / PHt / NHPP schedule carries a second time scale in its "
58 "breakpoints, which scaling the rates alone would leave inconsistent");
77 const std::size_t n = d.
params.size() / 2;
78 std::vector<T> mu(n), phi(n);
79 for (std::size_t i = 0; i < n; ++i) {
80 mu[i] = T(d.
params[i] * factor);
90 for (std::size_t i = 0; i < d.
D0.rows(); ++i)
91 for (std::size_t j = 0; j < d.
D0.cols(); ++j) A(i, j) = T(d.
D0(i, j) * factor);
99 for (std::size_t i = 0; i < d.
D0.rows(); ++i)
100 for (std::size_t j = 0; j < d.
D0.cols(); ++j) D0(i, j) = T(d.
D0(i, j) * factor);
101 for (std::size_t i = 0; i < d.
D1.rows(); ++i)
102 for (std::size_t j = 0; j < d.
D1.cols(); ++j) D1(i, j) = T(d.
D1(i, j) * factor);
104 for (
const T& p : d.
params) out.
params.push_back(T(p * factor));
124 "dist_scale_rate: scaling a Lognormal shifts its log-mean by log(factor), "
125 "which exact arithmetic has no representation for");
134 std::vector<T> s(d.
trace.size(), zero);
135 for (std::size_t i = 0; i < d.
trace.size(); ++i) s[i] = T(d.
trace[i] / factor);
143 "dist_scale_rate: rate scaling is not defined for this process family; supported are "
144 "Exp, Erlang, HyperExp, Coxian, Cox2, APH, PH, MAP, MMPP2, Det, Uniform, Gamma, Pareto, "
145 "Weibull, Lognormal, Replayer and Immediate");
UnsupportedError(const std::string &what)
The exception types the port throws.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
Dense matrix and non-owning view.
Distrib< T > dist_scale_rate(const Distrib< T > &d, const T &factor)
The law of X / factor, in the same family as d.
Number-type abstraction for the templated API port.
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
static Distrib replayer(const std::vector< T > &samples)
Replayer / Trace: the samples, with their empirical first two moments.
static Distrib exp_rate(const T &r)
static Distrib phase_type(const std::vector< T > &alpha, const Matrix< T > &A, bool acyclic)
PH / APH given by (alpha, A): D0 = A and D1 = (-A e) alpha.
static Distrib weibull(const T &scale, const T &shape)
bool has_schedule() const
static Distrib pareto(const T &shape, const T &scale)
Pareto(shape, scale), with the MATLAB parameter order (alpha, k).
std::vector< T > params
Constructor arguments, in MATLAB getParam order.
static Distrib gamma_dist(const T &shape, const T &scale)
Gamma(shape, scale), Weibull(scale, shape) and Lognormal(mu, sigma).
static Distrib map_dist(const Matrix< T > &D0, const Matrix< T > &D1, ProcessType tag)
A MAP given by its two matrices; the moments are those of its stationary phase.
std::vector< T > trace
Replayer / Trace samples; empty for every other type.
static Distrib det(const T &m)
static Distrib uniform(const T &a, const T &b)
Uniform(a, b).
static Distrib lognormal(const T &logmean, const T &logsigma)
static Distrib hyperexp(const T &p, const T &lambda1, const T &lambda2)
static Distrib immediate()
The Immediate singleton.
static Distrib erlang(const T &phase_rate, std::size_t r)
Erlang(alpha, r): r phases of rate alpha, as MATLAB's Erlang(phaseRate, nphases).
static Distrib coxian(const std::vector< T > &mu, const std::vector< T > &phi)
Coxian(mu, phi): phase i completes with probability phi(i) and otherwise moves to phase i+1.