![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Normalize a non-negative matrix into a stochastic transition matrix. More...
#include <cstddef>#include "line/num/number.h"#include "line/util/error.h"#include "line/util/matrix.h"Go to the source code of this file.
Namespaces | |
| namespace | line |
| namespace | line::mc |
Functions | |
| template<class T> | |
| Matrix< T > | line::mc::dtmc_makestochastic (const Matrix< T > &Pin) |
| Normalize a non-negative matrix into a stochastic transition matrix. | |
Normalize a non-negative matrix into a stochastic transition matrix.
Templated port of matlab/lib/kpctoolbox/mc/dtmc_makestochastic.m and jar/src/main/java/jline/api/mc/Dtmc_makestochastic.java. Each row with a positive sum is divided by that sum, and the diagonal entry then absorbs whatever deficit is left, clipped into [0,1]; a row that sums to zero is replaced by the unit vector on its own state, which turns a dead state into an absorbing one rather than leaving a substochastic row behind.
After the division the row already sums to one, so the diagonal update is an identity in exact arithmetic; it is kept because in floating point it is the step that removes the accumulated rounding of the division, and dropping it would make the double and exact paths disagree in the last bit.
Every operation is a field operation, so this is exact at Rational.
Definition in file dtmc_makestochastic.h.