| gamblersRuin | R Documentation |
Constructs the classic gambler's ruin chain: a gambler with a fortune
between 0 and upperBound wins each round (and gains one
unit) with probability prob, otherwise loses one unit; play stops
as soon as the fortune reaches 0 (ruin) or upperBound
(the gambler's target).
gamblersRuin(upperBound, prob, states = NULL)
upperBound |
A single positive integer: the fortune at which the
gambler stops (having won). The chain has |
prob |
A single number in |
states |
An optional character vector of |
This is the special case of birthDeath with constant birth
probability prob and constant death probability 1-prob at
every interior state, together forced to be absorbing rather than
merely reflecting at the two ends – which is why it is provided as its
own constructor rather than expressed purely in terms of
birthDeath(), which cannot produce absorbing boundaries by itself
(see toBoundedChain for turning any chain's ends
absorbing or reflecting after construction).
With prob != 0.5, the classical ruin probability of reaching
0 before upperBound, starting from fortune i, is
P(\text{ruin}\mid X_0=i) =
\frac{\left(\frac{1-\code{prob}}{\code{prob}}\right)^{i} -
\left(\frac{1-\code{prob}}{\code{prob}}\right)^{\code{upperBound}}}
{1-\left(\frac{1-\code{prob}}{\code{prob}}\right)^{\code{upperBound}}},
and i/\code{upperBound} when prob = 0.5; this is a standard
textbook result (see Norris (1998), Section 1.3) and is not itself
computed by this function, but can be read off from
absorptionProbabilities applied to the returned chain.
A new, row-stochastic markovchain object with
upperBound + 1 states. States "0" and
as.character(upperBound) are absorbing; every interior state
i has P_{i,i+1}=\code{prob} and P_{i,i-1}=1-\code{prob}.
Norris, J. R. (1998). Markov Chains. Cambridge University Press.
birthDeath, absorptionProbabilities,
toBoundedChain
ruin <- gamblersRuin(upperBound = 5, prob = 0.4)
ruin
absorbingStates(ruin)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.