| urnModel | R Documentation |
Constructs the Ehrenfest diffusion model: balls balls are split
between two urns, A and B; at each step, one of the balls balls is
chosen uniformly at random and moved to the other urn. The chain tracks
the number of balls in urn A.
urnModel(balls, states = NULL)
balls |
A single positive integer, the total number of balls. The
chain has |
states |
An optional character vector of |
The Ehrenfest model is the classical example of a chain whose
equilibrium behaviour matches thermodynamic intuition despite every
individual transition being fully reversible: its stationary
distribution is \mathrm{Binomial}(\code{balls}, 1/2) (each ball is,
at equilibrium, independently in urn A or B with probability 1/2),
sharply concentrated around \code{balls}/2 for large
balls even though the chain only ever moves one ball at a time
and is reflecting, not absorbing, at the boundaries. It is irreducible
and reversible for every balls, but periodic with period 2
(the parity of the ball count in urn A alternates every step): pass the
result through lazyChain first if an aperiodic chain is
needed, e.g. for mixingTime.
A new, row-stochastic markovchain object with
balls + 1 states. From state i (0<i<\code{balls}),
P_{i,i-1} = i/\code{balls}, \qquad P_{i,i+1} = 1 - i/\code{balls},
the probability that the ball moved was one of the i currently in
urn A (decreasing A's count) versus one of the \code{balls}-i
currently in urn B (increasing it). States 0 and balls
(all balls in one urn) are reflecting: the next ball moved must
come from the only non-empty urn, so P_{0,1}=P_{\code{balls},
\code{balls}-1}=1 exactly.
Ehrenfest, P. and Ehrenfest, T. (1907). Uber zwei bekannte Einwande gegen das Boltzmannsche H-Theorem. Physikalische Zeitschrift, 8, 311-314.
birthDeath, lazyChain
ehrenfest <- urnModel(balls = 4)
ehrenfest
steadyStates(ehrenfest) # approximately Binomial(4, 0.5): 1/16 6/16 ...
dbinom(0:4, 4, 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.