![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Random infinitesimal generator of a CTMC. More...
#include <cstddef>#include <cstdint>#include "line/api/mc/ctmc_solve.h"#include "line/num/number.h"#include "line/util/error.h"#include "line/util/matrix.h"Go to the source code of this file.
Classes | |
| class | line::mc::LcgUniform |
| Deterministic uniform [0,1) source, so that a caller who does not have one still has no reason to reach for a global stream. More... | |
Namespaces | |
| namespace | line |
| namespace | line::mc |
Functions | |
| template<class T, class Gen> | |
| Matrix< T > | line::mc::ctmc_rand (std::size_t n, Gen &gen) |
| Random infinitesimal generator of a CTMC. | |
Random infinitesimal generator of a CTMC.
Templated port of matlab/src/api/mc/ctmc_rand.m (identical to the kpctoolbox copy) and jar/src/main/java/jline/api/mc/Ctmc_rand.java: an n x n matrix of uniform [0,1) rates whose diagonal is then set by ctmc_makeinfgen.
The MATLAB and Java versions draw from a global stream (rand / randMatrix), so the caller has no way to reproduce a generator except by seeding that stream. Here the source of randomness is an explicit parameter: any callable returning a double in [0,1) with no global state. COMPARABILITY ACROSS IMPLEMENTATIONS THEREFORE REQUIRES THE SAME GENERATOR, and a matrix built here will not match one MATLAB built unless the same stream of variates is fed in; what is guaranteed is that two calls with equal generator states return the same matrix.
The variates are consumed in row-major order, one per off-diagonal and diagonal position alike (n*n draws), matching MATLAB's rand(n) column count only in total, not in order: MATLAB fills column-major. Pass the transpose of a MATLAB-filled stream if that ordering matters.
Only the diagonal is arithmetic, so this is exact at Rational whenever the generator's variates are (LcgUniform yields dyadic rationals, which are).
Definition in file ctmc_rand.h.