Professional Documents
Culture Documents
by Germán Riaño
Grupo COPA
griano@uniandes.edu.co
This workbook has a series of macros that can be used to analyze medium size Markov
Chain Problems. Its accuracy for large model has not been tested, and anyway Excel
cannot handle more than 256 columns
For really large models use:
jMarkov
Reference Manual
Reference
For steady state probabilities we mark the destination range and write
""=DTMCSteadyState(theP)" and then hit ctrl-shft-enter at the same time.
Attention: For all functions you have to hit Ctrl shift y enter at the same time.
Reducible Chains
1 2 3 4 5 6
1 0.1 0.2 0.1 0.2 0.2 0.2
2 0.2 0.3 0.1 0.3 0.1 0
3 0.1 0.3 0.2 0.2 0.1 0.1
4 0 0 0 0.2 0.8 0
5 0 0 0 0.8 0.2 0
6 0 0 0 0 0 1
Absortion Probabilities
Find R y Q, that correspond to transitions among transient and from transient the the closed comunicating class
1 2 3
1 0.1 0.2 0.1
A= 2 0.2 0.3 0.1 R=
3 0.1 0.3 0.2
Limit probability exists, since there are no periodic states, and is given by
1 2 3 4 5 6
1 0 0 0 #VALUE! #VALUE! #VALUE!
2 0 0 0 #VALUE! #VALUE! #VALUE!
3 0 0 0 #VALUE! #VALUE! #VALUE!
4 0 0 0 #VALUE! #VALUE! 0
5 0 0 0 #VALUE! #VALUE! 0
6 0 0 0 0 0 1
1 2 3 4 5 6
1 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
2 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
3 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
4 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
5 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
6 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
It works!
e closed comunicating classes
C1 C2
1 0.4 0.2
2 0.4 0
3 0.3 0.1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
Continuous Time Markov Chains
Go back to Main Menu
Define generator matrix Q y and call it "Generateor", via Insert/Name/Define
-9 4 5
Q= 10 -17 7
7 7 -14
Reducible Chains
Assume Q is given as
1 2 3 4 5 6
1 -9 2 1 2 2 2
2 12 -17 1 3 1 0
3 1 3 -8 2 1 1
4 0 0 0 -8 8 0
5 0 0 0 8 -8 0
6 0 0 0 0 0 0
T = {1,2,3}
C1 ={4,5}
C2 = {6}
Absortion Probabilities:
Absortion Probabilities:
DTMCAbsor(A,R)
C1 C2
1 #VALUE! #VALUE!
F= 2 #VALUE! #VALUE!
3 #VALUE! #VALUE!
1 2 3 4 5 6
1 0 0 0 #VALUE! #VALUE! #VALUE!
2 0 0 0 #VALUE! #VALUE! #VALUE!
3 0 0 0 #VALUE! #VALUE! #VALUE!
4 0 0 0 #VALUE! #VALUE! 0
5 0 0 0 #VALUE! #VALUE! 0
6 0 0 0 0 0 1
1 2 3 4 5 6
1 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
2 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
3 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
4 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
5 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
6 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
and it works!
C1 C2
1 4 2
2 4 0
3 3 1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
Reference Manual Go back to Main Menu
The following functions are defined in the Macros.
To use this functions in another worksheet save this workboos as an add-in (menu: File/Save
as, choose the last option)
If you plan to use the functions frequenlt you can install the add-in permanently (menu:
Tools/Addins)
General Matrix Functions
MatPower(A, n As Integer)
Computes the n-th power of the given matrix
λ=max (−qii )
Function UniformProb(Q, Optional EnsureGenerator As Boolean = True,
Optional lda = -1#)
Assuming Q is a generator matrix, computes the associated uniformized DTMC transition
matrix. If lda is not given it is internally computed. If EnsureGenerator is true then Q is
converted to a generator rather than a rates matrix
Q
P= +I
λ
DTMC Functions
MatExpo(A, t)
Computes exp(A x t)
DTMCMatOccup(A, n As Integer)
Computes the occupancy matrix for a Discrete Markov Chain
Function DTMCSteadyState(P)
Computes the steady state probability for DTMC with matix P. If P is not irreducible (or
unichain) this returns an error.
Function DTMCAbsor(A, R)
This computes the absorving probabilities for a markov chain with transient to transient
probabilities Q, and transient to absorving probabilities R, through the formula
( I − A )−1 R
I−
( (I−Q )−1 RA )−1 R
Function DTMCExpected(A)
Computes the expected number of steps before absorption, starting from each transient state,
through the formula
−1−1
( II−Q
− A) ) R1
1
CTMC Functions
Function CTMCSteadyState(Q)
Computes the steady state probabilities for the given generator matrix
Function CTMCMatOccup(Q, t)
Computed teh occupancy matrix
t
M (t )=∫0 P(s)ds
Function CTMCAbsor(A, R)
Computes teh absortion probabilities where A is the generator rates matrix from transient to
transient states, and R from transient to the absorving classes
Function CTMCExpected(A)
Computes the expected value of the time to absortion starting from each of the given states.
MarkovExcel Module
por Germán Riaño
Grupo COPA
griano@uniandes.edu.co
Esta herramienta de Excel tiene una serie de macros para el análisis de Cadenas de
Markov de tamaño intermedio. Su precisión para modelos muy grandes no has sido
probada y, en todo caso, Excel no maneja más de 256 columnas.
Para nodelos grandes use:
jMarkov
Manual de Referencia.
Referencia
Cadenas Reducibles
1 2 3 4 5 6
1 0.1 0.2 0.1 0.2 0.2 0.2
2 0.2 0.3 0.1 0.3 0.1 0
3 0.1 0.3 0.2 0.2 0.1 0.1
4 0 0 0 0.2 0.8 0
5 0 0 0 0.8 0.2 0
6 0 0 0 0 0 1
Probabilidades de Absorción:
Calculamos A y R
1 2 3
1 0.1 0.2 0.1
A= 2 0.2 0.3 0.1 R=
3 0.1 0.3 0.2
1 2 3 4 5 6
1 0 0 0 #VALUE! #VALUE! #VALUE!
2 0 0 0 #VALUE! #VALUE! #VALUE!
3 0 0 0 #VALUE! #VALUE! #VALUE!
4 0 0 0 #VALUE! #VALUE! 0
5 0 0 0 #VALUE! #VALUE! 0
6 0 0 0 0 0 1
1 2 3 4 5 6
1 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
2 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
3 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
4 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
5 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
6 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
y si lo es!
C1 C2
1 0.4 0.2
2 0.4 0
3 0.3 0.1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
Cadenas de Markov de Tiempo Continuo
Regresar al Menu Principal
Definimos la matriz generadora Q y le damos el nombre "Generateor", via Inserter/Nombre/Definir
-9 4 5
Q= 10 -17 7
7 7 -14
Cadenas Reducibles
Suponga que Q viene dada por
1 2 3 4 5 6
1 -9 2 1 2 2 2
2 12 -17 1 3 1 0
3 1 3 -8 2 1 1
4 0 0 0 -8 8 0
5 0 0 0 8 -8 0
6 0 0 0 0 0 0
T = {1,2,3}
C1 ={4,5}
C2 = {6}
Probabilidades de Absorción:
Calculamos A y R
1 2 3
1 -9 2 1
A= 2 12 -17 1 R=
3 1 3 -8
1 2 3 4 5 6
1 0 0 0 #VALUE! #VALUE! #VALUE!
2 0 0 0 #VALUE! #VALUE! #VALUE!
3 0 0 0 #VALUE! #VALUE! #VALUE!
4 0 0 0 #VALUE! #VALUE! 0
5 0 0 0 #VALUE! #VALUE! 0
6 0 0 0 0 0 1
1 2 3 4 5 6
1 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
2 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
3 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
4 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
5 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
6 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
y si lo es!
Nombre/Definir
C1 C2
1 4 2
2 4 0
3 3 1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
1
Check
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
Manual de Referencia Regresar al Menu Principal
(Lo siento, no tengo traducción.. Quizás Ud. quiera ayudarme..)
The following functions are defined in the Macros.
To use this functions in another worksheet save this workboos as an add-in (menu: File/Save
as, choose the last option)
If you plan to use the functions frequenlt you can install the add-in permanently (menu:
Tools/Addins)
General Matrix Functions
MatPower(A, n As Integer)
Computes the n-th power of the given matrix
λ=max (−qii )
Function UniformProb(Q, Optional EnsureGenerator As Boolean = True,
Optional lda = -1#)
Assuming Q is a generator matrix, computes the associated uniformized DTMC transition
matrix. If lda is not given it is internally computed. If EnsureGenerator is true then Q is
converted to a generator rather than a rates matrix
Q
P= +I
λ
DTMC Functions
MatExpo(A, t)
Computes exp(A x t)
DTMCMatOccup(A, n As Integer)
Computes the occupancy matrix for a Discrete Markov Chain
Function DTMCSteadyState(P)
Computes the steady state probability for DTMC with matix P. If P is not irreducible (or
unichain) this returns an error.
Function DTMCAbsor(A, R)
This computes the absorving probabilities for a markov chain with transient to transient
probabilities Q, and transient to absorving probabilities R, through the formula
( I − A )−1 R
( I − A )−1 R
Function DTMCExpected(A)
Computes the expected number of steps before absorption, starting from each transient state,
through the formula
−1
( I− A ) 1
CTMC Functions
Function CTMCSteadyState(Q)
Computes the steady state probabilities for the given generator matrix
Function CTMCMatOccup(Q, t)
Computed teh occupancy matrix
t
M (t )=∫0 P(s)ds
Function CTMCAbsor(A, R)
Computes teh absortion probabilities where A is the generator rates matrix from transient to
transient states, and R from transient to the absorving classes
Function CTMCExpected(A)
Computes the expected value of the time to absortion starting from each of the given states.
Principal