5#ifndef LINE_LANG_DIST_SCALE_RATE_H
6#define LINE_LANG_DIST_SCALE_RATE_H
51 throw InputError(
"dist_scale_rate: the scaling factor must be positive");
54 "dist_scale_rate: a Prior is a set of alternative models, not one law with a time "
55 "scale; perturb the alternatives instead");
58 "dist_scale_rate: a MAPt / PHt / NHPP / MMAPt / MPHt / BMMAPt schedule carries a "
59 "second time scale in its breakpoints, which scaling the rates alone would leave "
63 "dist_scale_rate: an NNPP carries a second time scale in its horizon, which scaling "
64 "the rates alone would leave inconsistent");
83 const std::size_t n = d.
params.size() / 2;
84 std::vector<T> mu(n), phi(n);
85 for (std::size_t i = 0; i < n; ++i) {
86 mu[i] = T(d.
params[i] * factor);
96 for (std::size_t i = 0; i < d.
D0.rows(); ++i)
97 for (std::size_t j = 0; j < d.
D0.cols(); ++j) A(i, j) = T(d.
D0(i, j) * factor);
104 Matrix<T> D0(d.
D0.rows(), d.
D0.cols(), zero), D1(d.
D1.rows(), d.
D1.cols(), zero);
105 for (std::size_t i = 0; i < d.
D0.rows(); ++i)
106 for (std::size_t j = 0; j < d.
D0.cols(); ++j) D0(i, j) = T(d.
D0(i, j) * factor);
107 for (std::size_t i = 0; i < d.
D1.rows(); ++i)
108 for (std::size_t j = 0; j < d.
D1.cols(); ++j) D1(i, j) = T(d.
D1(i, j) * factor);
110 for (
const T& p : d.
params) out.
params.push_back(T(p * factor));
137 "dist_scale_rate: scaling a Lognormal shifts its log-mean by log(factor), "
138 "which exact arithmetic has no representation for");
147 std::vector<T> s(d.
trace.size(), zero);
148 for (std::size_t i = 0; i < d.
trace.size(); ++i) s[i] = T(d.
trace[i] / factor);
156 "dist_scale_rate: rate scaling is not defined for this process family; supported are "
157 "Exp, Erlang, HyperExp, Coxian, Cox2, APH, PH, MAP, MMPP2, Det, Uniform, Gamma, Pareto, "
158 "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.
@ LOGLOGISTIC
Three reliability laws of Trivedi and Bobbio, "Reliability andAvailability Engineering" (2017),...
@ NNPP
A nonstationary non-Poisson arrival process (thinning + SCIATA): a rate function lambda(t) on [0,...
Distrib< T > dist_scale_rate(const Distrib< T > &d, const T &factor)
The law of X / factor, in the same family as d.
Conservation laws of a layered queueing network, enumerated from its structure.
Number-type abstraction for the templated API port.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
static Distrib loglogistic(const T &shape, const T &scale)
LogLogistic(shape, scale), stored in getParam order {alpha = scale, beta = shape}.
static Distrib replayer(const std::vector< T > &samples)
Replayer / Trace: the samples, with their empirical first two moments.
static Distrib defective(const Distrib &in, const T &pInf)
Defective(inner, pInf): infinite with probability pInf, else inner.
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 mass_at_origin(const Distrib &in, const T &p0)
MassAtOrigin(inner, p0): zero with probability p0, else inner.
std::shared_ptr< Distrib< T > > inner
The wrapped law of a MassAtOrigin or a Defective, null otherwise.
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)
HyperExp(p, lambda1, lambda2): phase i chosen with probability p_i.
static Distrib immediate()
The point mass at zero.
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.