subsymbol.org (Posts about probability)http://www.subsymbol.org/enContents © 2021 <a href="mailto:amber@cs.toronto.edu">L. Amber Wilcox-O'Hearn</a> Thu, 15 Apr 2021 03:05:14 GMTNikola (getnikola.com)http://blogs.law.harvard.edu/tech/rss- Pólya's Urnhttp://www.subsymbol.org/posts/polyas-urn.htmlL. Amber Wilcox-O'Hearn<div><p>Skip to interactive demo: <a class="reference internal" href="http://www.subsymbol.org/posts/polyas-urn.html#try-it">Try it!</a></p>
<section id="balls-in-urns">
<h2>Balls in Urns</h2>
<p>If you have studied probability, you are probably familiar with the canonical balls-in-an-urn allegory for understanding discrete probability distributions.
For example, you could imagine an urn containing 1 red ball and 3 green balls.
Drawing a ball from the urn at random represents sampling from a probability distribution where the probability of one outcome is <span class="math">\(25\%\)</span> and the probability of the other outcome is <span class="math">\(75\%\)</span>
We can extend this idea in a variety of ways.</p>
</section>
<section id="polya-s-urn">
<h2>Pólya's Urn</h2>
<p>In <em>Pólya's Urn</em>, the extension is that whenever you draw a ball from the urn, you not only replace it, but you add an extra ball of the same colour.
So if you happened to draw a green ball in the example above, then the ratio would change from <span class="math">\(1:3\)</span> to <span class="math">\(1:4\)</span>.
That means on the next draw, you would now have only a <span class="math">\(20\%\)</span> chance of drawing red.
On the other hand, if you happened to have drawn red, then the ratio would change to <span class="math">\(2:3\)</span>, giving red a probability of <span class="math">\(40\%\)</span></p>
<p>This process is interesting, because it has the property that the more often you observe something, the more likely you are to observe it again.</p>
</section>
<section id="different-starting-conditions">
<h2>Different starting conditions</h2>
<p>The way the distribution changes over time depends on the starting conditions.</p>
<section id="one-of-each">
<h3>One of each</h3>
<p>Let's imagine the simplest case, in which we start with one each of two colours, red and green.
The following table shows the probabilities of getting red on the first three draws, and how each draw changes the probability of the next by changing the proportion of colours in the urn.</p>
<table class="colwidths-given">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr><th class="head"></th>
<th class="head"><p>RRR</p></th>
<th class="head"></th>
</tr>
</thead>
<tbody>
<tr><td><p><strong>Draw</strong></p></td>
<td><p><strong>p(Draw)</strong></p></td>
<td><p><strong>new R:G</strong></p></td>
</tr>
<tr><td><p>R</p></td>
<td><p><span class="math">\(1/2\)</span></p></td>
<td><p>2:1</p></td>
</tr>
<tr><td><p>R</p></td>
<td><p><span class="math">\(2/3\)</span></p></td>
<td><p>3:1</p></td>
</tr>
<tr><td><p>R</p></td>
<td><p><span class="math">\(3/4\)</span></p></td>
<td><p>4:1</p></td>
</tr>
</tbody>
</table>
<hr class="docutils">
<p>There are more ways to have drawn two of one colour, and one of the other, than 3 of one colour.
However, because of the way drawing a particular colour reinforces itself,
there is a <span class="math">\(50\%\)</span> chance of drawing the same colour every time over the first three draws.</p>
<table class="colwidths-given">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr><th class="head"><p>First three draws</p></th>
<th class="head"><p>probability</p></th>
</tr>
</thead>
<tbody>
<tr><td><p>RRR</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 3/4 = 1/4\)</span></p></td>
</tr>
<tr><td><p>RRG</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 1/4 = 1/12\)</span></p></td>
</tr>
<tr><td><p>RGR</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 1/2 = 1/6\)</span></p></td>
</tr>
<tr><td><p>RGG</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 1/2 = 1/6\)</span></p></td>
</tr>
<tr><td><p>GRR</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 1/2 = 1/6\)</span></p></td>
</tr>
<tr><td><p>GRG</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 1/2 = 1/6\)</span></p></td>
</tr>
<tr><td><p>GGR</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 1/4 = 1/12\)</span></p></td>
</tr>
<tr><td><p>GGG</p></td>
<td><p><span class="math">\(1/2 \times 2/3 \times 3/4 = 1/4\)</span></p></td>
</tr>
</tbody>
</table>
</section>
<section id="ten-of-each">
<h3>Ten of each</h3>
<p>Now suppose that we start with 10 each of red and green balls.
In this case, simply drawing a red ball the first time does not change the probability that it will be drawn again nearly as significantly as with the <span class="math">\(1:1\)</span> starting conditions.
The probability of drawing 3 of the same colour in a row falls to <span class="math">\(2 \times 10/20 \times 11/21 \times 12/22 = 2/7 \cong 29\%\)</span></p>
<p>We can view the starting conditions as a list of numbers, one for each starting colour, and call it <em>alpha</em> (<span class="math">\(\alpha\)</span>).
So our first example had <span class="math">\(\alpha = [1, 3]\)</span>,
our second example had <span class="math">\(\alpha = [1, 1]\)</span>,
and our third example had <span class="math">\(\alpha = [10, 10]\)</span>,</p>
</section>
<section id="higher-returns">
<h3>Higher returns</h3>
<p>On the other hand, imagine if we started with 1 each of red and green, but instead of increasing the number of balls by 1 when we draw a colour, we increased it by 10.
Now every draw has a much stronger effect.
The probability of drawing the same colour 3 times in a row would now be <span class="math">\(2 \times 1/2 \times 11/12 \times 21/22 = 7/8 \cong 88\%\)</span></p>
<p>We could even have a particular increase number for each colour, and have another list, called <em>beta</em> (<span class="math">\(\beta\)</span>).</p>
</section>
<section id="more-colours">
<h3>More colours</h3>
<p>Another way to change the starting conditions is to increase the number of colours.
If our starting urn had one each of 10 different colours, then, again, when we draw the first ball, it has much less of an effect on the chance of drawing it again.
We can call the number of colours <span class="math">\(n\)</span>.</p>
</section>
</section>
<section id="try-it">
<h2>Try it!</h2>
<p>Use the sliders to choose <span class="math">\(n\)</span> colours, and a single <span class="math">\(\alpha\)</span> and <span class="math">\(\beta\)</span> for all colours. Try drawing balls from the urn, and see how the urn changes. At any time you can display the urn in rank order or reset to the current slider position.</p>
n: <b id="n-output"></b>
<input class="n-slider" type="range" min="1" max="8">
α: <b id="alpha-output"></b>
<input class="alpha-slider" type="range" min="1" max="8">
β: <b id="beta-output"></b>
<input class="beta-slider" type="range" min="1" max="8">
<br>
<p id="urn">Urn</p>
<br>
<button id="draw">Draw!</button>
<button id="reset">Reset.</button>
<button id="rank">Order by rank.</button>
<script src="http://www.subsymbol.org/scripts/polya.js">
</script></section></div>blogmathjaxprobabilityhttp://www.subsymbol.org/posts/polyas-urn.htmlFri, 25 Jul 2014 17:24:37 GMT