<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>thinkMoult &#187; bored</title>
	<atom:link href="http://thinkmoult.com/tag/bored/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkmoult.com</link>
	<description>Seriously who ever reads this description.</description>
	<lastBuildDate>Sun, 08 Apr 2012 03:22:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A little math probablility problem.</title>
		<link>http://thinkmoult.com/2009/07/07/a-little-math-probablility-problem/</link>
		<comments>http://thinkmoult.com/2009/07/07/a-little-math-probablility-problem/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 14:28:13 +0000</pubDate>
		<dc:creator>Dion Moult</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bored]]></category>
		<category><![CDATA[lol]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[nrich]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://thinkmoult.com/?p=739</guid>
		<description><![CDATA[I was originally planning tomorrow to post the new Perspective Magazine for you to ogle at (distribution on Friday!) but I shall delay that and you shall be rewarded for waiting with a PDF you can download of the magazine. Ooh. Instead tonight I had some free time (because tomorrow I shall be skiving school [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I was originally planning tomorrow to post the<a href="http://thinkmoult.com/2009/06/21/perspective-in-progress/"> new Perspective Magazine</a> for you to ogle at (distribution on Friday!) but I shall delay that and you shall be rewarded for waiting with a PDF you can download of the magazine. Ooh.</p>
<p>Instead tonight I had some free time (because tomorrow I shall be <span style="text-decoration: line-through;">skiving school</span> spending time productively at home) So I decided to look at an NRICH problem. Yes, that&#8217;s right. I was so bored I decided to do math. Edit: Apparently I didn&#8217;t notice the star rating system so it seems as though I picked an easy one.</p>
<p><a href="http://nrich.maths.org/public/viewer.php?obj_id=6550">Click to see problem: Succession in Randomia</a></p>
<p>Let&#8217;s consider a probability tree:</p>
<p style="text-align: center;"><a href="http://thinkmoult.com/wp-content/uploads/2009/07/Diagram2.png"><img class="size-full wp-image-741 aligncenter" title="Diagram2" src="http://thinkmoult.com/wp-content/uploads/2009/07/Diagram2.png" border="0" alt="Diagram2" width="356" height="181" /></a></p>
<p>&#8230; OK. The first thing we notice is that it looks prettier. Let&#8217;s see the series for B now: 1/4 + 1/16 + 1/64 + &#8230; . This is identical to T. We can do the same for L and say we have 2/8 + 2/32 + 2/128 &#8230; which is exactly the same as B and T. Plugging it into a/1-r (r being 1/4) we get 1/3 for all three. Hence we can say that in fact it is a completely unbiased way of choosing a successor.</p>
<p>My answer to that question is therefore: &#8220;<strong>Yeah they have an equal chance</strong>&#8221;</p>
<p>Well, I wasn&#8217;t going to stop here. Why don&#8217;t I simulate it? Here is the coding that simulates the situation (the cheapest brute force technique to tackle the problem):</p>
<p>If you don&#8217;t know programming, go take a read through the code anyway and see if you can get a grasp of what&#8217;s going on :)</p>
<p><code>&lt;?php<br />
// The number of times each king as won.<br />
$bingo = 0;<br />
$toto = 0;<br />
$lotto = 0;</p>
<p>// How many times we are going to do the crowning ceremony<br />
$ceremonies = 10000;</p>
<p>// Loop through these instructions to carry out the crowning ceremony.<br />
for ($i = 1; $i < $ceremonies+1; $i++)<br />
{<br />
    $win = FALSE; # Nobody has become king yet.<br />
    $oddeven = 1; # Because the first throw is odd. Assume 1 = odd, 0 = even.<br />
    $firsttoss = TRUE; # We are tossing for the first time.</p>
<p>    // This variable is used later to determine which variable $x or $y is<br />
    // reassigned a value and which keeps the previous toss value.<br />
    $a = 0;</p>
<p>    // Keep on tossing the coins until somebody wins the kingdom.<br />
    while ($win == FALSE)<br />
    {<br />
        // Here we only flip one coin, this will alternate between $x and $y.<br />
        // The one ($x or $y) that isn't assigned a new value will retain the<br />
        // previous toss value so we can find out whether or not we have got<br />
        // two HH or TT in a row.<br />
        // Assume H = 1, T = 2<br />
        if ($a == 0) {<br />
            $x = rand(1,2);<br />
            $a = $a + 1;<br />
        } elseif ($a > 0) {<br />
            $y = rand(1,2);<br />
            $a = 0;<br />
        }</p>
<p>        if ($firsttoss == TRUE) {<br />
            // Nobody can win on the first toss.<br />
            $firsttoss = FALSE;<br />
        } else {<br />
            // If it is HH and ODD...<br />
            if ($x == 1 &#038;&#038; $y == 1 &#038;&#038; $oddeven == 1) {<br />
                // Lotto will become King.<br />
                $lotto = $lotto + 1;</p>
<p>                // Somebody has won the Kingdom.<br />
                $win = TRUE;<br />
            }</p>
<p>            // If it is TT and ODD...<br />
            if ($x == 2 &#038;&#038; $y == 2 &#038;&#038; $oddeven == 1) {<br />
                // Lotto will become King.<br />
                $lotto = $lotto + 1;</p>
<p>                // Somebody has won the Kingdom.<br />
                $win = TRUE;<br />
            }</p>
<p>            // If it is HH and EVEN...<br />
            if ($x == 1 &#038;&#038; $y == 1 &#038;&#038; $oddeven == 0) {<br />
                // Bingo will become King.<br />
                $bingo = $bingo + 1;</p>
<p>                // Somebody has won the Kingdom.<br />
                $win = TRUE;<br />
            }</p>
<p>            // If it is TT and EVEN...<br />
            if ($x == 2 &#038;&#038; $y == 2 &#038;&#038; $oddeven == 0) {<br />
                // Toto will become King.<br />
                $toto = $toto + 1;</p>
<p>                // Somebody has won the Kingdom.<br />
                $win = TRUE;<br />
            }<br />
        }</p>
<p>        // ... If nobody has won anything ...<br />
        if ($win != TRUE) {<br />
            // We flip again, so Odd->Even or Even->Odd.<br />
            if ($oddeven == 0) {<br />
                $oddeven = 1;<br />
            } else {<br />
                $oddeven = 0;<br />
            }<br />
        }<br />
    }<br />
}</p>
<p>// Tell the computer to print out what results we have.<br />
echo 'Bingo: '. $bingo .'<br />';<br />
echo 'Toto: '. $toto .'<br />';<br />
echo 'Lotto: '. $lotto .'<br />';<br />
?&gt;</code></p>
<p>I ran it and here is an example result I get. Out of 10,000 ceremonies, this is the number of times each king has won:</p>
<p><strong>Bingo: 3322<br />
Toto: 3340<br />
Lotto: 3338</strong></p>
<p>Pretty close, eh?</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://thinkmoult.com/2009/07/07/a-little-math-probablility-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

