| toBoundedChain | R Documentation |
Replaces the transition rows of a markovchain object's first and
last state (in states(object) order) with an absorbing,
reflecting, or semi-reflecting rule, leaving every other row unchanged.
toBoundedChain(object, boundaryCondition)
## S4 method for signature 'markovchain'
toBoundedChain(object, boundaryCondition)
object |
A |
boundaryCondition |
Either:
|
This function assumes – as is standard for a boundary condition – that
states(object) is meaningfully ordered along a line, first state
to last state, as it would be e.g. for birthDeath or any
other chain built to represent a bounded random walk. It does not check
this (there is no general way to check it from the transition matrix
alone) and applies the same first/last-row replacement regardless of
object's actual structure; only the two boundary rows are ever
touched, so applying it to a chain whose states are not linearly ordered
simply reinterprets whichever states happen to be listed first and last.
Unlike gamblersRuin, which is absorbing at both ends by
construction and cannot be un-done, toBoundedChain() can be
applied to any existing chain and with any of the three conditions,
including reflecting or semi-reflecting ones that gamblersRuin()
does not offer directly.
The implementation touches only 2 of the n rows and is
O(n) time and memory beyond copying the transition matrix.
A new markovchain object, row-stochastic, on the same
states as object, identical to object except in its
first and last transition rows.
birthDeath, gamblersRuin
bd <- birthDeath(p = c(0.3, 0.4, 0.5), q = c(0.2, 0.3, 0.1))
absorbed <- toBoundedChain(bd, "absorbing")
absorbed@transitionMatrix[1, ]
absorbed@transitionMatrix[4, ]
reflected <- toBoundedChain(bd, "reflecting")
reflected@transitionMatrix[1, ]
semiReflected <- toBoundedChain(bd, 0.25)
semiReflected@transitionMatrix[1, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.