Example 3: Pólya's Urn

In this section, we'll model Pólya's Urn, a slightly more complicated stochastic process, in which the probability of a given event depends on the past events.

An urn contains two balls, one red and one blue. A ball is drawn at random. If it is red, it is returned to the urn and an additional red ball is also added. If it is blue, it is returned to the urn and an additional blue ball is added. This process of drawing and adding additional balls is repeated 100 times. What is the final distribution of red and blue balls in the urn?

We can write a function which describes what happens in a single draw. The function takes the number of balls of each color, i.e., the pair {red, blue} as an argument, and returns a new pair {red, blue} as a value. We use the If operator, which takes the form If[Condition, Value if True, Value if False].


A sample trajectory, starting with one ball of each color, is simply


This is the full set of data; from that, we might want to extract things like the number of red balls, or the fraction of red balls. To do this, we define functions numberRed and fractionRed, which operate on individual pairs, and then Map one of these functions onto the trajectory


A set of fractionRed trajectories might look like the following



Converted by Mathematica      November 5, 1999