Simulating the Bernoulli-Laplace Model of Diffusion

This Demonstration simulates a special discrete-time Markov chain, the so-called Bernoulli–Laplace model of diffusion. In this model, there are two urns; initially, urn I contains exactly black balls and urn II contains exactly white balls. Repeat the following experiment: one ball is selected at random from each of the urns. The ball selected from urn I is put into urn II and the ball selected from urn II is put into urn I. During such a sequence of experiments, we consider the number of white balls in urn I. The resulting random process is a discrete-time Markov chain.
The lower part of the Demonstration shows a simulated path of the process together with a confidence interval that has at least the probability 0.95. The upper part shows both the stationary distribution of the state of the process (the red broken line) and the empirical distribution calculated from the path shown (the blue broken line; the first 200 steps are rejected as transient).


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


Snapshot 1: 300 steps from which the last 100 steps are used to estimate the state probabilities; the estimated probabilities are quite poor
Snapshot 2: 600 steps from which the last 400 steps are used to estimate the state probabilities; the estimated probabilities are better but still differ considerably from the stationary distribution
Snapshot 3: 1200 steps from which the last 1000 steps are used to estimate the state probabilities; the estimated probabilities are quite close to the stationary distribution
For example, suppose there are 32 balls, 16 of which are white and 16 black. At the start of the simulation, urn I contains 0 white balls and 16 black balls. The number of white balls in urn I grows so that it has, in the long run, approximately 8 white balls and 8 black balls. From the snapshots, the probability that the state (the number of white balls in urn I) is between the green lines is 0.988 in a stationary situation, that is, the state is among 5, 6, 7, 8, 9, 10, and 11 with this probability. The green lines are calculated so that they give at least 95% confidence intervals (the given probability is exact).
We calculate the stationary probabilities from the well-known linear equations. However, the example considered allows a closed-form solution for the equations, see, [1, p. 398]. We use the equations to enable the user of the Demonstration to also easily simulate other discrete-time Markov chains.
When the empirical distribution is calculated, we reject the first 200 steps as transient.
For the Bernoulli-Laplace model of diffusion, see [1]. For simulation of the discrete-time Markov chain and other stochastic processes with Mathematica, see [2].
[1] W. Feller, An Introduction to Probability Theory and Its Applications, Vol. I, 3rd ed., revised printing, pp. 378, 397, New York: Wiley.
[2] H. Ruskeepää, Mathematica Navigator: Mathematics, Statistics, and Graphics, 3rd ed., pp. 987–1002, San Diego, CA: Elsevier Academic Press, 2009.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+