LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
CRPSolve.m
1% pi = CRPSolve(Q)
2%
3% Computes the stationary solution of a continuous time
4% rational process (CRP).
5%
6% Parameters
7% ----------
8% Q : matrix, shape (M,M)
9% The generator matrix of the rational process
10%
11% Returns
12% -------
13% pi : row vector, shape (1,M)
14% The vector that satisfies
15% `\pi\, Q = 0, \sum_i \pi_i=1`
16%
17% Notes
18% -----
19% Continuous time rational processes are like continuous
20% time Markov chains, but the generator does not have to
21% pass the :func:`CheckGenerator` test (but the rowsums
22% still have to be zeros).
23
24function pi = CRPSolve (Q)
25
26 global BuToolsCheckInput;
27 if isempty(BuToolsCheckInput)
28 BuToolsCheckInput = true;
29 end
30 global BuToolsCheckPrecision;
31 if isempty(BuToolsCheckPrecision)
32 BuToolsCheckPrecision = 1e-14;
33 end
34
35 if BuToolsCheckInput && any(abs(sum(Q,2))>BuToolsCheckPrecision)
36 error('CRPSolve: The matrix has a rowsum which isn''t zero!');
37 end
38
39 M = Q;
40 M(:,1) = 1;
41 m = zeros(1,size(M,1));
42 m(1) = 1.0;
43 pi = m/M;
44end