<?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>Probability and statistics blog &#187; r</title>
	<atom:link href="http://www.statisticsblog.com/category/r/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.statisticsblog.com</link>
	<description>In Monte Carlo We Trust</description>
	<lastBuildDate>Mon, 16 Jan 2012 01:30:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Iowa: Was the fix in? (a statistical analysis of the results)</title>
		<link>http://www.statisticsblog.com/2012/01/iowa-was-the-fix-in-a-statistical-analysis-of-the-results/</link>
		<comments>http://www.statisticsblog.com/2012/01/iowa-was-the-fix-in-a-statistical-analysis-of-the-results/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 18:29:54 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[elections]]></category>
		<category><![CDATA[polling]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=594</guid>
		<description><![CDATA[Summary/TL;DR Either the first precincts to report were widely unrepresentative of Iowa as a whole, or something screwy happened. Background Yesterday was the first primary for the 2012 U.S. presidential elections. When I logged off the internet last night, the results in Iowa showed a dead heat between Ron Paul, Mitt Romney, and Rick Santorum. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Summary/TL;DR</strong><br />
Either the first precincts to report were widely unrepresentative of Iowa as a whole, or something screwy happened.</p>
<p><strong>Background</strong><br />
Yesterday was the first primary for the 2012 U.S. presidential elections. When I logged off the internet last night, the results in Iowa showed a dead heat between Ron Paul, Mitt Romney, and Rick Santorum. When I woke up this morning and checked the results from my phone, they were very different. So before connecting to the internet, I took a screen shot of what I saw before going to bed. Here it is:</p>
<p><a href="http://www.statisticsblog.com/wp-content/uploads/2012/01/Before.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2012/01/Before-1024x724.gif" alt="" title="Before" width="550" class="alignnone size-large wp-image-606" /></a></p>
<p>Then I connected to the internet and refreshed that page:</p>
<p><a href="http://www.statisticsblog.com/wp-content/uploads/2012/01/After.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2012/01/After-1024x757.gif" alt="" title="After" width="550" class="alignnone size-large wp-image-607" /></a></p>
<p>It seemed strange to me that the results should change so dramatically after 25% of the votes had already been recorded. As a statistician, my next question was: how unusual is this? That&#8217;s a question that can be tested. In particular, I can test how often you might have a split of voters like the one shown in the first screen shot, if the final split is like the one shown in the other screen shot, given that the first precincts to report were similar to later ones in voter composition.</p>
<p>That&#8217;s a lot to digest all at once, so I&#8217;m going to repeat and clarify exactly what I&#8217;m assuming, and what I&#8217;m going to test.</p>
<p><strong>The assumptions</strong><br />
First, I assume the following:<br />
1. That CNN was showing the correct partial results as they became available. Similarly, I am assuming that the amount shown with 99% of votes reported (second screen shot) is the true final tally, give or take some insignificant amount.</p>
<p>2. That the precincts to report their vote totals first were a random sampling of the precincts overall. Given how spread out these appear to be in the first screen shot, this seems like a good assumption. But that might not be the case. See the end of this post for more about that possibility.</p>
<p>3. No fraud, manipulation, or other shenanigans occurred in terms of counting up the votes and reporting them. </p>
<p><strong>The test</strong><br />
Given these three assumptions, I&#8217;m going to come up with a numeric value for the following:<br />
1. What is the probability that the split, at 25% of the vote tallied, would show Ron Paul, Mitt Romney, and Rick Santorum all above 6,200 votes.</p>
<p>It&#8217;s possible to come up with a theoretical value for this probability using a formal statistical test. If you decide to work this out, make sure to take into account the fact that your initial sample size (25%) is large compared to the total population. You&#8217;ll also need to factor in all of the candidates. Could get messy.</p>
<p>For my analysis, I used <a href="http://www.statisticsblog.com/manifesto/" target="_new">the tool I trust</a>: Monte Carlo simulation. I created a simulated population of 121,972 votes, with 26,219 who favor Ron Paul, 30,015 who favor Mitt Romney, and so on. Then I sampled 27,009 from them (the total votes tallied as of the first screen shot). Then I looked at the simulated split as of that moment, and saw if the three top candidates at the end are all above 6,200 votes. What about just Ron Paul?</p>
<p>I&#8217;ve coded my simulation using the programming language R, you can see my code at the end of this post. </p>
<p><strong>The results</strong><br />
Out of 100,000 simulations, this result came up not even once! In all those trials, Ron Paul never broke 6,067 votes at the time of the split.  </p>
<p>I ran this test a couple times, and each time the result was the same. </p>
<p><strong>Conclusion</strong><br />
If my three assumptions are correct, the probability of observing partial results like we saw is <em>extremely</em> small. It&#8217;s much more likely that one of the assumptions is wrong. It could be that the early reports were wrong, though that seems unlikely. The other websites showed the same information or very similar, so it seems doubtful that an error occurred in passing along the information. </p>
<p>Was there something odd about the precincts that reported early? This is not something you could tell just by looking at split vs final data. The data clearly show that the later precincts disfavored Ron Paul, but that&#8217;s just what we want to know: did they <em>really</em> disfavor him, or was the data manipulated in some way. The question is, were any of the results faked, tweaked, massaged, Diebold-ed? </p>
<p>To answer that question, we&#8217;d need to know if these later precincts to report were expected, beforehand, to disfavor Ron Paul relative to the others. It would also help to look at entrance polling from all of the precincts, and compare the ones that were part of the early reporting versus those that were part of the later reports. At this point, I have to ask for help from you, citizen of the internet. Is this something we can figure out?</p>
<p><strong>UPDATE</strong><br />
In case folks are interested, here&#8217;s a histogram of the 100,000 simulations. This shows the distribution of votes for Ron Paul as of the split, given the assumptions. As you can see it&#8217;s a nice bell curve, which it should be. Also note how far out on the curve 6,240 would be.<br />
<a href="http://www.statisticsblog.com/wp-content/uploads/2012/01/RPvotes.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2012/01/RPvotes.gif" alt="" title="RPvotes" width="550" height="550" class="alignnone size-full wp-image-613" /></a></p>
<p><strong>The code</strong><br />
Oh, one final possibility is that I messed up my code. You can check it below and see:</p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># Code for StatisticsBlog.com by Matt Asher</span>
&nbsp;
<span style="color: #228B22;"># Vote amounts</span>
splits <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;MR&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">6297</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RS&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">6256</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RP&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">6240</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;NG&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">3596</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;JRP&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">2833</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;MB&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">1608</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;JH&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">169</span>
splits<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;HC&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">10</span>
&nbsp;
finals <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;MR&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">30015</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RS&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">30007</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RP&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">26219</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;NG&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">16251</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;JRP&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">12604</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;MB&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">6073</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;JH&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">745</span>
finals<span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;HC&quot;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">58</span>
&nbsp;
<span style="color: #228B22;"># Get an array with all voters:</span>
population <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>name <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">names</span><span style="color: #080;">&#40;</span>finals<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    population <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>population, <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span>name, finals<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span>name<span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># This was the initial split</span>
initialSplit <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>name <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">names</span><span style="color: #080;">&#40;</span>splits<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    initialSplit <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>initialSplit, <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span>name, splits<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span>name<span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #228B22;"># How many times to pull a sample</span>
iters <span style="color: #080;">=</span> <span style="color: #ff0000;">100000</span>
&nbsp;
<span style="color: #228B22;"># Sample size equal to the size at split</span>
sampleSize <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>initialSplit<span style="color: #080;">&#41;</span>
&nbsp;
successes <span style="color: #080;">=</span> <span style="color: #ff0000;">0</span>
justRPsuccesses <span style="color: #080;">=</span> <span style="color: #ff0000;">0</span>
&nbsp;
<span style="color: #228B22;"># Track how many votes RP gets at the split</span>
rpResults <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>, iters<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>iters<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	ourSample <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">sample</span><span style="color: #080;">&#40;</span>population, sampleSize, <span style="color: #0000FF; font-weight: bold;">replace</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">F</span><span style="color: #080;">&#41;</span>
	results <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">table</span><span style="color: #080;">&#40;</span>ourSample<span style="color: #080;">&#41;</span>
&nbsp;
	rpResults<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> results<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RP&quot;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">;</span>
&nbsp;
	<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>results<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RP&quot;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&gt;</span><span style="color: #ff0000;">6200</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		justRPsuccesses <span style="color: #080;">=</span> justRPsuccesses <span style="color: #080;">+</span> <span style="color: #ff0000;">1</span>
&nbsp;
		<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>results<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;MR&quot;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&gt;</span><span style="color: #ff0000;">6200</span> <span style="color: #080;">&amp;</span> results<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">&quot;RS&quot;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&gt;</span><span style="color: #ff0000;">6200</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			successes <span style="color: #080;">=</span> successes <span style="color: #080;">+</span> <span style="color: #ff0000;">1</span>
		<span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">cat</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Had a total of&quot;</span>, successes, <span style="color: #ff0000;">&quot;out of&quot;</span>, iters, <span style="color: #ff0000;">&quot;trials, for a proportion of&quot;</span>, successes<span style="color: #080;">/</span>iters, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">cat</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;RP had a total of&quot;</span>, justRPsuccesses, <span style="color: #ff0000;">&quot;out of&quot;</span>, iters, <span style="color: #ff0000;">&quot;trials, for a proportion of&quot;</span>, justRPsuccesses<span style="color: #080;">/</span>iters, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2012/01/iowa-was-the-fix-in-a-statistical-analysis-of-the-results/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>My oh my</title>
		<link>http://www.statisticsblog.com/2011/12/my-oh-my/</link>
		<comments>http://www.statisticsblog.com/2011/12/my-oh-my/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 01:01:06 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[Ryan Gosling]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=565</guid>
		<description><![CDATA[Noted without comment, visit Biostatistics Ryan Gosling !!! for more gems like the one above.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2011/12/Ryan_Gosling-Biostatistics.jpg"><img src="http://www.statisticsblog.com/wp-content/uploads/2011/12/Ryan_Gosling-Biostatistics.jpg" alt="" title="Ryan_Gosling-Biostatistics" width="550" height="603" class="alignnone size-full wp-image-566" /></a></p>
<p>Noted without comment, visit <a href="http://biostatisticsryangosling.tumblr.com/" target="_new" rel="nofollow">Biostatistics Ryan Gosling !!!</a> for more gems like the one above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2011/12/my-oh-my/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Wasting away again in Martingaleville</title>
		<link>http://www.statisticsblog.com/2011/12/wasting-away-again-in-martingaleville/</link>
		<comments>http://www.statisticsblog.com/2011/12/wasting-away-again-in-martingaleville/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 04:56:10 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[gambling]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[financial crisis]]></category>
		<category><![CDATA[martingale]]></category>
		<category><![CDATA[martingale betting]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=557</guid>
		<description><![CDATA[Alright, I better start with an apology for the title of this post. I know, it&#8217;s really bad. But let&#8217;s get on to the good stuff, or, perhaps more accurately, the really frightening stuff. The plot shown at the top of this post is a simulation of the martingale betting strategy. You&#8217;ll find code for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2011/12/Martingale.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2011/12/Martingale.gif" alt="" title="Martingale" width="558" height="551" class="alignnone size-full wp-image-558" /></a></p>
<p>Alright, I better start with an apology for the title of this post. I know, it&#8217;s really bad. But let&#8217;s get on to the good stuff, or, perhaps more accurately, the really frightening stuff. The plot shown at the top of this post is a simulation of the martingale betting strategy. You&#8217;ll find code for it <a href="http://www.statisticsblog.com/code/martingaleBetting.r">here</a>. What is the martingale betting strategy? Imagine you go into a a mythical casino that gives you perfectly fair odds on the toss of a mythically perfect coin. You can bet one dollar or a million. Heads you lose the amount you bet, tails you win tjat same amount. For your first bet, you wager $1. If you win, great! Bet again with a dollar. If you lose, double your wager to $2. Then if you win the next time, you&#8217;ve still won $1 overall (lost $1 then won $2). In general, continue to double your bet size until you get a win, then drop your bet size back down to a dollar. Because the probably of an infinite loosing streak is infinitely small, sooner or later you&#8217;ll make $1 off of the sequence of bets. Sound good?</p>
<p>The catch (you knew there had to be a catch, right?) is that the longer you use the martingale strategy, the more likely you are to go broke, unless you have an infinitely large bankroll. Sooner or later, a run of heads will wipe out your entire fortune. That&#8217;s what the plot at the beginning of this post shows. Our simulated gambler starts out with $1000, grows her pot up to over $12,000 (with a few bumps along the way), then goes bankrupt during a single sequence of bad luck. In short, the martingale stagy worked spectacularly well for her (12-fold pot increase!) right up until the point where it went spectacularly wrong (bankruptcy!). </p>
<p>Pretty scary, no? But I haven&#8217;t even gotten to the really scary part. In an <a href="http://www.youtube.com/watch?v=v5qomm4g2rk&#038;t=16m20s" target="_new">interview with financial analyst Karl Denninger</a>, Max Keiser explains the martingale betting strategy then comments:</p>
<p>&#8220;This seems to be what every Wall Street firm is doing. They are continuously loosing, but they are doubling down on every subsequent throw, because they know that they&#8217;ve got unlimited cash at their disposal from The Fed&#8230; Is this a correct way to describe what&#8217;s going on?</p>
<p>Karl Denninger replies. &#8220;I think it probably is. I&#8217;m familiar with that strategy. It bankrupts everyone who tries it, eventually&#8230;. and that&#8217;s the problem. Everyone says that this is an infinite sum of funds from the Federal Reserve, but in fact there is no such thing as an infinite amount of anything.&#8221;</p>
<p>Look at the plot at the beginning of this post again. Imagine the top banking executives in your country were paid huge bonuses based on their firm&#8217;s profits, and in the case of poor performance they got to walk away with a generous severance package. Now imagine that these companies could borrow unlimited funds at 0% interest, and if things really blew up they expected the taxpayers to cover the tab through bailouts or inflation. Do you think this might be a recipe for disaster? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2011/12/wasting-away-again-in-martingaleville/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Queueing up in R, continued</title>
		<link>http://www.statisticsblog.com/2011/10/queueing-up-in-r-continued/</link>
		<comments>http://www.statisticsblog.com/2011/10/queueing-up-in-r-continued/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 14:03:15 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[queueing theory]]></category>
		<category><![CDATA[simulations]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=516</guid>
		<description><![CDATA[Shown above is a queueing simulation. Each diamond represents a person. The vertical line up is the queue; at the bottom are 5 slots where the people are attended to. The size of each diamond is proportional to the log of the time it will take them to be attended. Color is used to tell [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2011/10/AnimationConverted2.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2011/10/AnimationConverted2.gif" alt="" title="AnimationConverted2" width="550" height="550" class="alignnone size-full wp-image-522" /></a></p>
<p>Shown above is a queueing simulation. Each diamond represents a person. The vertical line up is the queue; at the bottom are 5 slots where the people are attended to. The size of each diamond is proportional to the log of the time it will take them to be attended. Color is used to tell one person from another and doesn&#8217;t have any other meaning. Code for this simulation, written in R, is <a href="http://www.statisticsblog.com/code/queueing2.r" target="_new">here</a>. This is my second post about queueing simulation, you can find the first one, including an earlier version of the code, <a href="http://www.statisticsblog.com/2011/10/waiting-in-line-waiting-on-r" target="_new"000000>here</a>. Thanks as always to commenters for their suggestions. </p>
<p>A few notes about the simulation:</p>
<ul>
<li>Creating an animation to go along with your simulation can take a while to program (unless, perhaps, you are coding in Flash), and it may seem like an extra, unnecessary step. But you can often learn a lot just by &#8220;watching&#8221;, and animations can help you spot bugs in the code. I noticed that sometimes smaller diamonds hung around for much longer then I expected, which led me to track down a tricky little error in the code.</li>
<li>As usual, I&#8217;ve put all of the configuration options at the beginning of the code. Try experimenting with different numbers of intervals and tellers/slots, or change the mean service time.</li>
<li>If you want to run the code, you&#8217;ll need to have ImageMagick installed. If you are on a PC, make sure to include the full path to &#8220;convert&#8221;, since Windows has a built-in convert tool might take precedence. Also, note how the files that represent the individual animation cells are named. That&#8217;s so that they are added in the animation in the right order, naming them sequentially without zeros at the beginning failed.</li>
<li>I used Photoshop to interlace the animated GIF and resave. This reduced the file size by over 90%</li>
<li>The code is still a work in progress, it needs cleanup and I still have some questions I want to &#8220;ask&#8221; of the simulation.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2011/10/queueing-up-in-r-continued/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Waiting in line, waiting on R</title>
		<link>http://www.statisticsblog.com/2011/10/waiting-in-line-waiting-on-r/</link>
		<comments>http://www.statisticsblog.com/2011/10/waiting-in-line-waiting-on-r/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 15:40:27 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[banks]]></category>
		<category><![CDATA[queueing theory]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=504</guid>
		<description><![CDATA[I should state right away that I know almost nothing about queuing theory. That&#8217;s one of the reasons I wanted to do some queuing simulations. Another reason: when I&#8217;m waiting in line at the bank, I tend to do mental calculations for how long it should take me to get served. I look at the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2011/10/QueueLengthsOverTime.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2011/10/QueueLengthsOverTime.gif" alt="" title="QueueLengthsOverTime" width="610" height="592" class="alignnone size-full wp-image-507" /></a></p>
<p>I should state right away that I know almost nothing about queuing theory. That&#8217;s one of the reasons I wanted to do some queuing simulations. Another reason: when I&#8217;m waiting in line at the bank, I tend to do mental calculations for how long it <em>should</em> take me to get served. I look at the number of tellers attending, pick an average teller session length (say one or two minutes), then come up with an average wait per person in line. For example, if there are 4 tellers and the average person takes 2 minutes to do her transaction, then new tellers should become available every 30 seconds. If I&#8217;m the 6th person in line, I should expect to wait 3 minutes before I&#8217;m attended.</p>
<p>However, based on my experience (the <a href="http://www.statisticsblog.com/2010/06/five-dumb-arguments-smart-people-make/#anecdotal" target="_new">much maligned anecdotal</a>), it often takes much longer than expected. My suspicion is that over time the teller&#8217;s get &#8220;clogged up&#8221; with the slowest people, so that even though an average person might take only 2 minutes, the people you actually see being attended right now are much more likely to be those who take a long time. </p>
<p>To explore this possibility, I set up a simulation in R (as usual, full source code provided at end of post). The first graph, at the beginning of this post, shows the length of queues over time for 4 runs of the simulator, all with the same configuration parameters. Often this graph was completely flat. Note though that when things get out of hand in terms of queue length, they can get way out of hand. To get a feel for how long you would have to wait, given that there is a line in front of you, I tracked how long the first person in line had to wait to be served. Given my configuration settings, this wait would be expected to last 5 intervals. It does seem to take longer than 5 intervals, though I want to tweak the model some and do more testing before I&#8217;m ready to quantify that wait.</p>
<p>There are, as with any models, things that make this one unrealistic. The biggest may be that people get in line with the same probability no matter how long the line is. What I need is some kind of tendency to abandon the line if it&#8217;s too long. That shouldn&#8217;t shorten the wait times for those already in line. I could make those worse. If you assume that slower people are prepared to wait longer in line, then the line is more likely to have slow people. Grandpa Jones is willing to spend an hour in line so he can chat for a while with the pretty young teller; but if the line is too long, that 50-year-old business guy will come back later to deposit his check. I would imagine that, from the bank&#8217;s perspective, this presents a tricky dilemma. The people whose time is worth the least are probably the most likely to be clogging up your tellers, upsetting the customers you care the most about (I know, I know, Bank of America cares about all of us equally, right?). </p>
<p>Code so far, note that run times can be very long for high intervals if the queue length gets long:</p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;">#### Code by Matt Asher. Published at StatisticsBlog.com ####</span>
<span style="color: #228B22;">#### CONFIG ####</span>
<span style="color: #228B22;"># Number of slots to fill</span>
numbSlots <span style="color: #080;">=</span> <span style="color: #ff0000;">5</span>
&nbsp;
<span style="color: #228B22;"># Total time to track</span>
intervals <span style="color: #080;">=</span> <span style="color: #ff0000;">1000</span>
&nbsp;
<span style="color: #228B22;"># Probability that a new person will show up during an interval</span>
<span style="color: #228B22;"># Note, a maximum of one new person can show up during an interval</span>
p <span style="color: #080;">=</span> <span style="color: #ff0000;">0.1</span>
&nbsp;
<span style="color: #228B22;"># Average time each person takes at the teller, discretized exponential distribution assumed</span>
<span style="color: #228B22;"># Times will be augmented by one, so that everyone takes at least 1 interval to serve</span>
meanServiceTime <span style="color: #080;">=</span> <span style="color: #ff0000;">25</span>
&nbsp;
<span style="color: #228B22;">#### INITIALIZATION ####</span>
queueLengths <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>, intervals<span style="color: #080;">&#41;</span>
slots <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>, numbSlots<span style="color: #080;">&#41;</span>
waitTimes <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
leavingTimes <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
queue <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
arrivalTimes <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
frontOfLineWaits <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #228B22;">#### Libraries ####</span>
<span style="color: #228B22;"># Use the proto library to treat people like objects in traditional oop</span>
<span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;proto&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">#### Functions ####</span>
<span style="color: #228B22;"># R is missing a nice way to do ++, so we use this</span>
inc <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
  <span style="color: #0000FF; font-weight: bold;">eval.<span style="">parent</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">substitute</span><span style="color: #080;">&#40;</span>x <span style="color: #080;">&lt;-</span> x <span style="color: #080;">+</span> <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># Main object, really a &quot;proto&quot; function</span>
<span style="color: #0000FF; font-weight: bold;">person</span> <span style="color: #080;">&lt;-</span> proto<span style="color: #080;">&#40;</span>
	intervalArrived <span style="color: #080;">=</span> <span style="color: #ff0000;">0</span>,
	intervalAttended <span style="color: #080;">=</span> NULL,
&nbsp;
	<span style="color: #228B22;"># How much teller time will this person demand?</span>
	intervalsNeeded <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">floor</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">rexp</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">/</span>meanServiceTime<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">+</span> <span style="color: #ff0000;">1</span>,
	intervalsWaited <span style="color: #080;">=</span> <span style="color: #ff0000;">0</span>,
	intervalsWaitedAtHeadOfQueue <span style="color: #080;">=</span> <span style="color: #ff0000;">0</span>,
<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">#### Main loop ####</span>
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>intervals<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<span style="color: #228B22;"># Check if anyone is leaving the slots</span>
	<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>j <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>numbSlots<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>slots<span style="color: #080;">&#91;</span>j<span style="color: #080;">&#93;</span> <span style="color: #080;">==</span> i<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			<span style="color: #228B22;"># They are leaving the queue, slot to 0</span>
			slots<span style="color: #080;">&#91;</span>j<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">0</span>
			leavingTimes <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>leavingTimes, i<span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># See if a new person is to be added to the queue</span>
	<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">runif</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;</span> p<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		newPerson <span style="color: #080;">=</span> as.<span style="">proto</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">person</span>$as.<span style="">list</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
		newPerson$intervalArrived <span style="color: #080;">=</span> i
		queue <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>queue, newPerson<span style="color: #080;">&#41;</span>
		arrivalTimes  <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>arrivalTimes, i<span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># Can we place someone into a slot?</span>
	<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>j <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>numbSlots<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<span style="color: #228B22;"># Is this slot free</span>
		<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span>slots<span style="color: #080;">&#91;</span>j<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>queue<span style="color: #080;">&#41;</span> <span style="color: #080;">&gt;</span> <span style="color: #ff0000;">0</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
				placedPerson <span style="color: #080;">=</span> queue<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span>
				slots<span style="color: #080;">&#91;</span>j<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> i <span style="color: #080;">+</span> placedPerson$intervalsNeeded
				waitTimes <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>waitTimes, placedPerson$intervalsWaited<span style="color: #080;">&#41;</span>
				<span style="color: #228B22;"># Only interested in these if person waited 1 or more intevals at front of line</span>
				<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>placedPerson$intervalsWaitedAtHeadOfQueue<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
					frontOfLineWaits <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span>frontOfLineWaits, placedPerson$intervalsWaitedAtHeadOfQueue<span style="color: #080;">&#41;</span>
				<span style="color: #080;">&#125;</span>
&nbsp;
				<span style="color: #228B22;"># Remove placed person from queue</span>
				queue<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> NULL
			<span style="color: #080;">&#125;</span>
		<span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># Everyone left in the queue has now waited one more interval to be served</span>
	<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>queue<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>j <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>queue<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			inc<span style="color: #080;">&#40;</span>queue<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span>j<span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span>$intervalsWaited<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># = queue[[j]]$intervalsWaited + 1</span>
		<span style="color: #080;">&#125;</span>
&nbsp;
		<span style="color: #228B22;"># The (possibley new) person at the front of the queue has had to wait there one more interval.</span>
		inc<span style="color: #080;">&#40;</span>queue<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span>$intervalsWaitedAtHeadOfQueue<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># = queue[[1]]$intervalsWaitedAtHeadOfQueue + 1</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># End of the interval, what is the state of things</span>
	queueLengths<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>queue<span style="color: #080;">&#41;</span><span style="color: #080;">;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;">#### Output ####</span>
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>queueLengths, type<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;o&quot;</span>, <span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;blue&quot;</span>, pch<span style="color: #080;">=</span><span style="color: #ff0000;">20</span>, main<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Queue lengths over time&quot;</span>, xlab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Interval&quot;</span>, ylab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Queue length&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;"># plot(waitTimes, type=&quot;o&quot;, col=&quot;blue&quot;, pch=20, main=&quot;Wait times&quot;, xlab=&quot;Person&quot;, ylab=&quot;Wait time&quot;)</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2011/10/waiting-in-line-waiting-on-r/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>R: Attack of the hair-trigger bees?</title>
		<link>http://www.statisticsblog.com/2011/01/r-attack-of-the-hair-trigger-bees/</link>
		<comments>http://www.statisticsblog.com/2011/01/r-attack-of-the-hair-trigger-bees/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 01:50:36 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[bees]]></category>
		<category><![CDATA[collective intelligence]]></category>
		<category><![CDATA[simulations]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=469</guid>
		<description><![CDATA[In their book &#8220;Complex Adaptive Systems&#8221;, authors Miller and Page create a theoretic model for bee attacks, based on the real, flying, honey-making, photogenic stingers. Suppose the hive is threatened by some external creature. Some initial group of guard bees sense the danger and fly off to attack. As they go, they lay down a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2011/01/BeeAttacks.gif"><img class="alignnone size-full wp-image-470" title="BeeAttacks" src="http://www.statisticsblog.com/wp-content/uploads/2011/01/BeeAttacks.gif" alt="" width="660" height="605" /></a></p>
<p>In their book &#8220;Complex Adaptive Systems&#8221;, authors Miller and Page create a theoretic model for bee attacks, based on the real, flying, honey-making, photogenic stingers. Suppose the hive is threatened by some external creature. Some initial group of guard bees sense the danger and fly off to attack. As they go, they lay down a scent. Other bees join in the attack if their scent sensitivity threshold (SST) is reached. When they join the attack, they send out their own warning scent, perhaps triggering an even bigger attack. The authors make the point that if the colony of bees were homogeneous, and every single one had the same attack threshold, then if that threshold was above the initial attack number, then no one else would join in. If it were below, then everyone goes all at once. Fortunately for the bees, they are a motley lot, which is to say a lot more diverse than you would imagine just from looking at the things. As a result, they exhibit much more complicated behavior. The authors describe a model with 100 bees and call their attack threshold &#8220;R&#8221;. By assuming a heterogeneous population of 100 with thresholds all equal spaced, they note:</p>
<blockquote><p>&#8220;In the hetrogeneous case, a full-scall attack ensues for <img src='http://s.wordpress.com/latex.php?latex=R%20%5Cgeq%201&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='R \geq 1' title='R \geq 1' class='latex' />. This latter result is easy to see, because once at least one bee attacks, then the bee with threshold equal to one will join the fray, and this will trigger the bee with the next highest threshold to join in, and so on&#8230;. It is relatively difficult to get the homogeneous hive to react, while the hetrogeneous one is on a hair trigger. Without explicity incorporating the diversity of thresholds, it is difficult to make any kind of accurate prediction of how a given hive will behave.&#8221;</p></blockquote>
<p>I think this last sentence is their way of noting that the exact distribution of sensitivities makes a <i>huge</i> difference in how the bees behave, which indeed it does. I decided to put the bees to the test, so I coded a simulation in the language R (code at the end of this post). I gave 100 virtual <i>apis mellifera</i> a random sensitivity level, chosen from a Uniform(1,100) distribution, then assumed 10 guards decided to attack. How would the others respond? Would a hair-trigger chain reaction occur? The chart at the top shows the results from 1000 trials. Looks pretty chaotic, so here&#8217;s a histogram of the results:</p>
<p> <a href="http://www.statisticsblog.com/wp-content/uploads/2011/01/BeeFrequencies.gif"><img src="http://www.statisticsblog.com/wp-content/uploads/2011/01/BeeFrequencies.gif" alt="" title="BeeFrequencies" width="626" height="643" class="alignnone size-full wp-image-472" /></a></p>
<p>As you can see, most of the time the chain reaction dies out quickly, with no more than 20 new bees joining in the attack. However, occasionally the bees do go nuts, sending the full on attack. This happened about 1 percent of the time. Perhaps most interestingly, all of the other attack levels were clearly possible as well, in the flat zone from about 30 to 95. You might want to try playing with the distribution of the sensitivities and see if you get any other interesting distributions. Meanwhile, if you decide to raid a hive, make sure to dip yourself in mud first, that way the bees will think you are nothing but an <a href="http://www.youtube.com/watch?v=XP1vPfSCYQs" target="_new">innocent black rain cloud</a>.</p>
<p>Code in R:</p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;">trials <span style="color: #080;">=</span> <span style="color: #ff0000;">1000</span>
&nbsp;
go <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,trials<span style="color: #080;">&#41;</span>
initial <span style="color: #080;">=</span> <span style="color: #ff0000;">10</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>trials<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
  bees <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">runif</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">100</span>,<span style="color: #ff0000;">1</span>,<span style="color: #ff0000;">100</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
  <span style="color: #228B22;"># Everyone who's threshold is less than the inital amount goes.</span>
  going <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>bees<span style="color: #080;">&#91;</span>bees<span style="color: #080;">&lt;</span>initial<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
&nbsp;
  <span style="color: #228B22;"># See if this number now goes up as new bees join in</span>
  <span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>going <span style="color: #080;">&gt;</span> initial<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    more <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>bees<span style="color: #080;">&#91;</span>bees<span style="color: #080;">&lt;</span>going<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
    <span style="color: #0000FF; font-weight: bold;">while</span> <span style="color: #080;">&#40;</span>more <span style="color: #080;">&gt;</span> going<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    <span style="color: #228B22;"># Keep doing this until it stops</span>
      going <span style="color: #080;">=</span> more
      more <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>bees<span style="color: #080;">&#91;</span>bees<span style="color: #080;">&lt;</span>going<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
    <span style="color: #080;">&#125;</span>  
    going <span style="color: #080;">=</span> more
  <span style="color: #080;">&#125;</span> 
  go<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> going
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">par</span><span style="color: #080;">&#40;</span>mar<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">4</span>,<span style="color: #ff0000;">4</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">plot.<span style="">ts</span></span><span style="color: #080;">&#40;</span>go,lwd<span style="color: #080;">=</span><span style="color: #ff0000;">1.5</span>,<span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;blue&quot;</span>, bty<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;n&quot;</span>, xlab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Trial&quot;</span>, ylab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Number of bees who join attack&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
windows<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">hist</span><span style="color: #080;">&#40;</span>go, breaks<span style="color: #080;">=</span><span style="color: #ff0000;">50</span>, <span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;blue&quot;</span>, xlab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Number of bees to join attack&quot;</span>, main<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Frequency of different attack sizes&quot;</span><span style="color: #080;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2011/01/r-attack-of-the-hair-trigger-bees/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Livin&#8217; la Vida Poisson</title>
		<link>http://www.statisticsblog.com/2010/11/livin-la-vida-poisson/</link>
		<comments>http://www.statisticsblog.com/2010/11/livin-la-vida-poisson/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 02:20:59 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[epistomology]]></category>
		<category><![CDATA[probability]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[chimes]]></category>
		<category><![CDATA[exponential]]></category>
		<category><![CDATA[poisson]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=443</guid>
		<description><![CDATA[Yes, I did just mix English, Spanish and French. And no, I living the &#8220;fishy&#8221; life, popular opinion to the contrary. Here&#8217;s the story. As someone who spends the majority of his time working online, with no oversight, I notice that I tend to drift a lot. I don&#8217;t play solitaire, or farm for virtual [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I did just mix English, Spanish and French. And no, I living the &#8220;fishy&#8221; life, popular opinion to the contrary. Here&#8217;s the story. As someone who spends the majority of his time working online, with no oversight, I notice that I tend to drift a lot. I don&#8217;t play solitaire, or farm for virtual carrots, but I do wander over to Reddit more than I should, or poke around in this or that market in virtual assets to see if anything interesting has shown up. To some extent this can be justified. Many, perhaps all, of my profitable ventures have come from keeping my eyes open, poking around, doing my best to understand the digital world. On the other hand, at times I feel like I&#8217;ve been drifting aimlessly, that I&#8217;m all drift and no focus. My existing projects are gathering dust while I chase after shiny new things. </p>
<p>That&#8217;s the feeling, anyway. What does the evidence say? To keep track of what I was really doing, and perhaps nudge me towards more focus, I set a stopwatch to go off every 15 minutes. When it did, I would stop, write down what I was doing at that moment, and continue on. Perhaps you can see how these set intervals might provide an incentive to, shall we say, cheat? Especially right after the stopwatch chimed, I knew that whatever I did for the next few minutes was &#8220;free&#8221;, untracked. So I decided that I would have to write down everything I did during those 15 minute intervals, which worked sometimes, othertimes not so well.</p>
<p>My current solution? Setup a bell which chimes at random intervals, with an average time between chimes of 15 minutes. To hear what the bell sounds like, Go ahead and <a href="http://www.statisticsblog.com/whatamidoing/" target="_new">try it out</a>, I think you&#8217;ll find it makes a nice sound. Go ahead and leave that page open while you read the rest of this post, see how many times it rings.  </p>
<p>At any rate, in order to randomize how long the wait was between chimes, I used a little something called a Poisson process. Actually, what I used was the Binomial approximation to the Poisson built from multiple Bernoulli trials, which results in wait times that are Exponential. Wait! Did you get all that? If so, then skip ahead until things look interesting. Otherwise, here&#8217;s more detail about how this works:</p>
<p>In order to determine the length of time between chimes, my computer generates a random number number between 0 and 1. If this random number is less than 1/15, then the next chime is in just one minute. Otherwise, the computer generates another random number and adds one minute to the time between chimes. On average, it will take 15 tries to get a number below 1/15, so the average time between chimes will be 15 minutes. However, to call 15 minutes the average is somewhat misleading. Here are the frequencies of different wait times (source code in R at the end):</p>
<p><a href="http://www.statisticsblog.com/wp-content/uploads/2010/11/Poisson_exponential.png"><a href="http://www.statisticsblog.com/wp-content/uploads/2010/11/Poisson_to_Exponential.gif"><img class="alignnone size-full wp-image-448" title="Poisson_to_Exponential" src="http://www.statisticsblog.com/wp-content/uploads/2010/11/Poisson_to_Exponential.gif" alt="" width="551" height="516" /></a><br />
</a></p>
<p>As you can see, the most common time between chimes is just one minute. Strange, no? What&#8217;s going on here is that each test to see if the random number is below 1/15 is a Bernoulli trial, which is basically Italian for &#8220;maybe it succeeds, maybe it fails&#8221;. In this case &#8220;success&#8221; has probability of 1/15, failure happens the other 14 out of 15 times. In cases where probability is small, and you end of doing a lot of trials, the total number of successes over a given time period will have the Poisson distribution. The &#8220;Poisson&#8221; here is a Frenchman, who may or may not have smelled like his surname, but who certainly understood The Calculus as well as anyone in the early 1800&#8242;s. To get an even better approximation of the Poisson, I could have used trails with probability of success of 1/900, then treated each failure as another second of waiting time. That would have made the graph above smoother. </p>
<p>But wait! I didn&#8217;t show you a graph of the Poisson. I showed you a graph of something that approximates the exponential distribution. The number of chimes per hour is (roughly) Poisson distributed, but the waiting time between each chime is exponential, which means shorter wait times are more frequent, but no length of time, no matter how long, can be ruled out. In fact, the exponential distribution is the only (continuous) distribution which is &#8220;memoryless&#8221;. If you have waited 15 minutes for a chime, your expected wait time is still&#8230;. 15 minutes. In fact, your expected wait is independent of how long you have waited so far. The exponential distribution is a &#8220;maximal entropy&#8221; distribution, entropy in this case is related to how much you know. With the exponential, no matter how long you&#8217;ve waited, you still don&#8217;t know anything more than when you started waiting. </p>
<p>If you&#8217;ve been tuning out and scanning this post, now would be a good time to tune back in. I promise new and interesting things ahead!</p>
<p>It&#8217;s one things to understand the memoryless property of the exponential, even down to the mathematical nitty-gritty. It&#8217;s quite another to actually live with the exponential. No matter how well I know the formulas, I can&#8217;t shake the felling that the longer I have waited in between bell rings, the sooner the next chime must be coming. Certainly, it should be due any time now! While I &#8220;know&#8221; that any given minute has exactly the same probably as the next to bring with it the bell, the longer I wait, the nearer I feel the the next chime must be. After all, the back of my mind insists, once the page loads the wait time has been set into stone. However it was distributed before, it&#8217;s now a constant. Every minute you wait you are getting closer to the next bell, whenever it might have been set to come. I keep <em>wanting</em> to know more than I did a minute ago about about when the next bell will arrive.</p>
<p>This isn&#8217;t the only way in which I find my psyche battling with my intellect. I would also swear that over time the distribution of short waits and long waits evens out. Now, by the law of large numbers, it&#8217;s true that the more chimes I sit through, the closer the mean wait time will approach 15 minutes. However, even if you&#8217;ve just heard three quick bells in a row, that has absolutely no bearing on how long the wait will be between the next three chimes. The expected wait times going forward are completely independent of the wait times in the past. The mean remains 15 minutes, the median remains 10.4 minutes. Yet that&#8217;s not what I <em>feel</em> is happening, and over the past two weeks of experimenting with this I would swear that on days when there are a number of unusually quick intervals, these have been followed, later that very the same day, with unusually long intervals. And vice versa. It feels like things are evening out.</p>
<p>It&#8217;s possible that when my computer wakes up from a sleep mode, my web browser doesn&#8217;t remember where it was in a countdown to refreshing the chime page. So I reload it. Now, in theory, if you &#8220;reload&#8221; an exponential wait time while in process, this has absolutely no effect on your eventual wait time until the next chime. Yet anytime I reload the page, I have a moment of doubt as to whether I&#8217;m &#8220;cheating&#8221; in some way, to make what would have been a long wait shorter. In this case, the back of my mind says the exact opposite of its previous bias: because I am reloading a page that has been waiting a long time, this means that the wait time would have been <em>really</em> long. By starting the process anew, I&#8217;m increasing the chances of a short chime time. </p>
<p>Before you call me a nut, try living for a while with the timer running the background. Keep track of what you are doing if you want (and BTW I&#8217;ve found this to be every enlightening and more than a little sad), but mostly keep track of how you feel about the timing. Try reloading the page if you don&#8217;t hear a chime for a while. How does that feel? I suspect that in some ways humans were very well hard wired to understand <em>probabilities</em>. Yet I also suspect our wiring hinders how we understand <em>probability</em>, a suspicion backed up by all those gamblers out there waiting for the lucky break that&#8217;s well overdue. </p>
<p><strong>CODE:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;">iters <span style="color: #080;">=</span> <span style="color: #ff0000;">1000</span>
results <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,iters<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>iters<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	minutes <span style="color: #080;">=</span> <span style="color: #ff0000;">1</span>
	<span style="color: #0000FF; font-weight: bold;">while</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">runif</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&gt;</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">/</span><span style="color: #ff0000;">15</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#123;</span>
		minutes <span style="color: #080;">=</span> minutes <span style="color: #080;">+</span> <span style="color: #ff0000;">1</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	results<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> minutes
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">hist</span><span style="color: #080;">&#40;</span>results, breaks<span style="color: #080;">=</span><span style="color: #ff0000;">40</span>, <span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;blue&quot;</span>, xlab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Minutes&quot;</span><span style="color: #080;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2010/11/livin-la-vida-poisson/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Weekend art in R (Part 4)</title>
		<link>http://www.statisticsblog.com/2010/09/weekend-art-in-r-part-4/</link>
		<comments>http://www.statisticsblog.com/2010/09/weekend-art-in-r-part-4/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 12:38:23 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[circles]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=429</guid>
		<description><![CDATA[Computer creations are perfect by design. We put in numbers, and if all goes well we get out an exact result. If we want a line, we want it perfectly straight. If we want a circle, it should conform to the platonic ideal of a circle. From a mathematical standpoint, these perfect shapes and precisely [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2010/09/ManyCircles.png"><img class="alignnone size-full wp-image-430" title="ManyCircles" src="http://www.statisticsblog.com/wp-content/uploads/2010/09/ManyCircles.png" alt="" width="600" height="575" /></a></p>
<p>Computer creations are perfect by design. We put in numbers, and if all goes well we get out an exact result. If we want a line, we want it perfectly straight. If we want a circle, it should conform to the platonic ideal of a circle. From a mathematical standpoint, these perfect shapes and precisely computed numbers are ideal.</p>
<p>Someday, perhaps, we will have true fuzzy computation built right into our hardware. For now, it takes considerable effort to achieve just the right level of imperfection needed for simulating mistakes, or any organic processes.</p>
<p>I sent each of the circles shown above on a random walk. That part was easy, getting each circle to end up where it started (and close the loop) took a bit more effort. To vary the &#8220;wigglyness&#8221; of the lines, adjust the &#8220;sd&#8221; parameter in &#8220;rnorm&#8221;. To change how quickly randomness tapers off, change the &#8220;4&#8243; in &#8220;i/4&#8243;. Here is my code:</p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># Circle lengths</span>
j <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">seq</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0.1</span>,<span style="color: #ff0000;">1.9</span>,.08<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">par</span><span style="color: #080;">&#40;</span>bg <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;black&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #080;">-</span><span style="color: #ff0000;">2</span>,<span style="color: #080;">-</span><span style="color: #ff0000;">2</span>,pch<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;.&quot;</span>,xlim<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">-</span><span style="color: #ff0000;">2</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span>,ylim<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #080;">-</span><span style="color: #ff0000;">2</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span>,<span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># How many dots around the circle?</span>
dots <span style="color: #080;">=</span> <span style="color: #ff0000;">1000</span>
&nbsp;
<span style="color: #228B22;"># Create an offkilter circle</span>
rads <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">seq</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">*</span><span style="color: #0000FF; font-weight: bold;">pi</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">*</span><span style="color: #0000FF; font-weight: bold;">pi</span><span style="color: #080;">/</span>dots<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>aLength <span style="color: #0000FF; font-weight: bold;">in</span> j<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<span style="color: #228B22;"># Pick a random color</span>
	myCol <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;#&quot;</span>,<span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">sample</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">9</span>,<span style="color: #ff0000;">&quot;A&quot;</span>,<span style="color: #ff0000;">&quot;B&quot;</span>,<span style="color: #ff0000;">&quot;C&quot;</span>,<span style="color: #ff0000;">&quot;D&quot;</span>,<span style="color: #ff0000;">&quot;E&quot;</span>,<span style="color: #ff0000;">&quot;F&quot;</span><span style="color: #080;">&#41;</span>,<span style="color: #ff0000;">6</span>,<span style="color: #0000FF; font-weight: bold;">replace</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">T</span><span style="color: #080;">&#41;</span>,collapse<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span>,collapse<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span>,sep<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># Start at length = 1, then walk.</span>
	myLength <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span>aLength,dots<span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">2</span><span style="color: #080;">:</span>dots<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> myLength<span style="color: #080;">&#91;</span><span style="color: #080;">&#40;</span>i<span style="color: #080;">-</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">+</span> <span style="color: #0000FF; font-weight: bold;">rnorm</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span>,<span style="color: #ff0000;">0</span>,<span style="color: #0000FF; font-weight: bold;">sd</span><span style="color: #080;">=</span>.005<span style="color: #080;">&#41;</span>
&nbsp;
		<span style="color: #228B22;"># Closer we are to end, faster we return to where started so circle closes</span>
		<span style="color: #0000FF; font-weight: bold;">dist</span> <span style="color: #080;">=</span> aLength <span style="color: #080;">-</span> myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span>
		myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> aLength <span style="color: #080;">-</span> <span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">dist</span><span style="color: #080;">*</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#40;</span>dots<span style="color: #080;">-</span><span style="color: #080;">&#40;</span>i<span style="color: #080;">/</span><span style="color: #ff0000;">4</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">/</span><span style="color: #080;">&#40;</span>dots<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>dots<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<span style="color: #0000FF; font-weight: bold;">cat</span><span style="color: #080;">&#40;</span>myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">*</span><span style="color: #0000FF; font-weight: bold;">cos</span><span style="color: #080;">&#40;</span>rads<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>,myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">*</span><span style="color: #0000FF; font-weight: bold;">sin</span><span style="color: #080;">&#40;</span>rads<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>,<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #080;">&#41;</span>
		<span style="color: #0000FF; font-weight: bold;">points</span><span style="color: #080;">&#40;</span>myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">*</span><span style="color: #0000FF; font-weight: bold;">cos</span><span style="color: #080;">&#40;</span>rads<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>,myLength<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">*</span><span style="color: #0000FF; font-weight: bold;">sin</span><span style="color: #080;">&#40;</span>rads<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>,<span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span>myCol,pch<span style="color: #080;">=</span><span style="color: #ff0000;">20</span>,cex<span style="color: #080;">=</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
<span style="color: #080;">&#125;</span></pre></div></div>

<p><a href="http://www.statisticsblog.com/wp-content/uploads/2010/09/circles2.gif"><img class="alignnone size-full wp-image-432" title="circles2" src="http://www.statisticsblog.com/wp-content/uploads/2010/09/circles2.gif" alt="" width="600" height="572" /></a></p>
<p>What do your circles look like?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2010/09/weekend-art-in-r-part-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Chosen One</title>
		<link>http://www.statisticsblog.com/2010/08/the-chosen-one/</link>
		<comments>http://www.statisticsblog.com/2010/08/the-chosen-one/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 21:41:43 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[probability]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[Matthew effect]]></category>
		<category><![CDATA[monte carlo]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=422</guid>
		<description><![CDATA[Toss one hundred different balls into your basket. Shuffle them up and select one with equal probability amongst the balls. That ball you just selected, it&#8217;s special. Before you put it back, increase its weight by 1/100th. Then put it back, mix up the balls and pick again. If you do this enough, at some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2010/08/TheChosenOneSimple.gif"><img class="alignnone size-full wp-image-423" title="TheChosenOneSimple" src="http://www.statisticsblog.com/wp-content/uploads/2010/08/TheChosenOneSimple.gif" alt="" width="600" height="549" /></a></p>
<p>Toss one hundred different balls into your basket. Shuffle them up and select one with equal probability amongst the balls. That ball you just selected, it&#8217;s special. Before you put it back, increase its weight by 1/100th. Then put it back, mix up the balls and pick again. If you do this enough, at some point there will be a consistent winner which begins to stand out.</p>
<p>The graph above shows the results of 1000 iterations with 20 balls (each victory increases the weight of the winner by 5%). The more balls you have, the longer it takes before a clear winner appears. Here&#8217;s the graph for 200 balls (0.5% weight boost for each victory).</p>
<p><a href="http://www.statisticsblog.com/wp-content/uploads/2010/08/MoreItemsMoreIterations.gif"><img class="alignnone size-full wp-image-424" title="MoreItemsMoreIterations" src="http://www.statisticsblog.com/wp-content/uploads/2010/08/MoreItemsMoreIterations.gif" alt="" width="600" height="574" /></a></p>
<p>As you can see, in this simulation it took about 85,000 iterations before a clear winner appeared. </p>
<p>I contend that as the number of iterations grows, the probability of seeing a Chosen One approaches unity, no matter how many balls you use. In other words, for any number of balls, a single one of them will eventually see its relative weight, compared to the others, diverge. Can you prove this is true?</p>
<p>BTW this is a good Monte Carlo simulation of the <a href="http://en.wikipedia.org/wiki/Matthew_effect" target="_blank" rel="nofollow">Matthew Effect</a> (no relation).</p>
<p>Here is the code in <a href="http://www.statisticsblog.com/glossary/#r">R</a> to replicate:</p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;">numbItems <span style="color: #080;">=</span> <span style="color: #ff0000;">200</span>
items <span style="color: #080;">=</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>numbItems
itemWeights <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">/</span>numbItems,numbItems<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># Start out uniform</span>
iterations <span style="color: #080;">=</span> <span style="color: #ff0000;">100000</span>
itemHistory <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,iterations<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>iterations<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	chosen <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">sample</span><span style="color: #080;">&#40;</span>items, <span style="color: #ff0000;">1</span>, prob<span style="color: #080;">=</span>itemWeights<span style="color: #080;">&#41;</span>
	itemWeights<span style="color: #080;">&#91;</span>chosen<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> itemWeights<span style="color: #080;">&#91;</span>chosen<span style="color: #080;">&#93;</span> <span style="color: #080;">+</span> <span style="color: #080;">&#40;</span>itemWeights<span style="color: #080;">&#91;</span>chosen<span style="color: #080;">&#93;</span> <span style="color: #080;">*</span> <span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">/</span>numbItems<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	itemWeights <span style="color: #080;">=</span> itemWeights <span style="color: #080;">/</span> <span style="color: #0000FF; font-weight: bold;">sum</span><span style="color: #080;">&#40;</span>itemWeights<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># re-Normalze</span>
	itemHistory<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> chosen
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>itemHistory, <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>iterations, pch<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;.&quot;</span>, <span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;blue&quot;</span><span style="color: #080;">&#41;</span></pre></div></div>

<p>After many trials using a fixed large number of balls and iterations, I found that the moment of divergence was amazingly consistent. Do you get the same results? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2010/08/the-chosen-one/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Weekend art in R (Part 3)</title>
		<link>http://www.statisticsblog.com/2010/08/weekend-art-in-r-part-3/</link>
		<comments>http://www.statisticsblog.com/2010/08/weekend-art-in-r-part-3/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 11:50:17 +0000</pubDate>
		<dc:creator>Matt Asher</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[cairo]]></category>

		<guid isPermaLink="false">http://www.statisticsblog.com/?p=414</guid>
		<description><![CDATA[I have a few posts nearing completion, but meanwhile a weekend break for art. Big thanks to Simon Urbanek and Jeffrey Horner, creators of Cairo, a library for the programming language R. Have you noticed how R can&#8217;t anti-alias (fancy way for saying smooth out lines and curves when creating a bit-mapped image)? Cairo can. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.statisticsblog.com/wp-content/uploads/2010/08/DotArt.gif"><img class="alignnone size-full wp-image-415" title="DotArt" src="http://www.statisticsblog.com/wp-content/uploads/2010/08/DotArt.gif" alt="" width="550" height="550" /></a></p>
<p>I have a few posts nearing completion, but meanwhile a weekend break for art. Big thanks to Simon Urbanek and Jeffrey Horner, creators of Cairo, a library for the programming language R. Have you noticed how R can&#8217;t anti-alias (fancy way for saying smooth out lines and curves when creating a bit-mapped image)? Cairo can.</p>
<p>Make sure to click the image above for the full version. Here&#8217;s my code:</p>

<div class="wp_syntax"><div class="code"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># The Cairo library produces nice, smooth graphics</span>
Cairo<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1200</span>, <span style="color: #ff0000;">1200</span>, <span style="color: #0000FF; font-weight: bold;">file</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;D:/Your/Path/Here/Dots.png&quot;</span>, type<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;png&quot;</span>, bg<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;#FF6A00&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># How big should the grid for placing dots be?</span>
myWidth<span style="color: #080;">=</span><span style="color: #ff0000;">40</span>
myHeight<span style="color: #080;">=</span><span style="color: #ff0000;">40</span>
&nbsp;
dotsPlaced <span style="color: #080;">=</span> myWidth<span style="color: #080;">*</span>myHeight
&nbsp;
<span style="color: #228B22;"># Optional default colors and sizes for dots</span>
myColors <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;#0000F0&quot;</span>,<span style="color: #ff0000;">&quot;#00F000&quot;</span><span style="color: #080;">&#41;</span>,dotsPlaced<span style="color: #080;">&#41;</span>
myCex <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">3.2</span>,dotsPlaced<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>dotsPlaced<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<span style="color: #228B22;"># Change this to allow more of the default color dots to survive</span>
	<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">runif</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&lt;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		myColors<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;#&quot;</span>,<span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">sample</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">3</span><span style="color: #080;">:</span><span style="color: #ff0000;">9</span>,<span style="color: #ff0000;">&quot;A&quot;</span>,<span style="color: #ff0000;">&quot;B&quot;</span>,<span style="color: #ff0000;">&quot;C&quot;</span>,<span style="color: #ff0000;">&quot;D&quot;</span>,<span style="color: #ff0000;">&quot;E&quot;</span>,<span style="color: #ff0000;">&quot;F&quot;</span><span style="color: #080;">&#41;</span>,<span style="color: #ff0000;">6</span>,<span style="color: #0000FF; font-weight: bold;">replace</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">T</span><span style="color: #080;">&#41;</span>,collapse<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span>,collapse<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span>,sep<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
	myCex<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">runif</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span>,<span style="color: #ff0000;">3</span>,<span style="color: #ff0000;">6</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># Keeping this is marginal</span>
<span style="color: #0000FF; font-weight: bold;">par</span><span style="color: #080;">&#40;</span>oma<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">par</span><span style="color: #080;">&#40;</span>mar<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># Start off with a blank plot. The white dot helps with cropping later</span>
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span>,pch<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;.&quot;</span>,xlim<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">40</span><span style="color: #080;">&#41;</span>,ylim<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">40</span><span style="color: #080;">&#41;</span>,<span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;white&quot;</span>, xaxt <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;n&quot;</span>, yaxt <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>m <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>myWidth<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>n <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>myHeight<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">runif</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;</span> .93<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			<span style="color: #0000FF; font-weight: bold;">points</span><span style="color: #080;">&#40;</span>n,m,pch<span style="color: #080;">=</span><span style="color: #ff0000;">20</span>,<span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span>myColors<span style="color: #080;">&#91;</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#40;</span>m<span style="color: #080;">*</span>n<span style="color: #080;">&#41;</span><span style="color: #080;">+</span>n<span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>,cex<span style="color: #080;">=</span>myCex<span style="color: #080;">&#91;</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#40;</span>m<span style="color: #080;">*</span>n<span style="color: #080;">&#41;</span><span style="color: #080;">+</span>n<span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">dev.<span style="">off</span></span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># Tell Cairo to burn the plot to disk</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.statisticsblog.com/2010/08/weekend-art-in-r-part-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

