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].

[Graphics:../Images/index_gr_46.gif]

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

[Graphics:../Images/index_gr_47.gif]

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

[Graphics:../Images/index_gr_48.gif]

A set of fractionRed trajectories might look like the following

[Graphics:../Images/index_gr_49.gif]
[Graphics:../Images/index_gr_50.gif]
[Graphics:../Images/index_gr_51.gif]

[Graphics:../Images/index_gr_52.gif]


Converted by Mathematica      November 5, 1999