<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Computing in the classroom</title>
	<atom:link href="http://bit-player.org/2009/computing-in-the-classroom/feed" rel="self" type="application/rss+xml" />
	<link>http://bit-player.org/2009/computing-in-the-classroom</link>
	<description>An amateur's outlook on computation and mathematics.</description>
	<pubDate>Thu, 17 May 2012 09:48:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Mathew</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2174</link>
		<dc:creator>Mathew</dc:creator>
		<pubDate>Thu, 09 Jul 2009 04:21:23 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2174</guid>
		<description>Well the spam screening confused me for a little while...lol

Excellent your solutions seems to be a lot better and easier to understand.</description>
		<content:encoded><![CDATA[<p>Well the spam screening confused me for a little while&#8230;lol</p>
<p>Excellent your solutions seems to be a lot better and easier to understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2117</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Fri, 17 Apr 2009 16:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2117</guid>
		<description>Barry:

It's not enough that I make all the mistakes around here? I have to diagnose and explicate them as well? 

I'm working on it. But I'm busy. I still have a day job. I could use a little help. So let me throw the question back at you.

Suppose I ask you to choose &lt;em&gt;n&lt;/em&gt; numbers uniformly at random from the interval [0,1) and calculate their product. You reason that the numbers will have an average value of 1/2, and so the expectation value of the product is 1/2^&lt;em&gt;n&lt;/em&gt;.

Now I suggest a slightly different procedure. Again you select a number uniformly at random from the interval [0,1). The selected number -- call it &lt;em&gt;p&lt;/em&gt; -- partitions the interval into two subintervals, [0,&lt;em&gt;p&lt;/em&gt;) and [p,1). Choose one of these subintervals at random and select a new &lt;em&gt;p&lt;/em&gt; from this range. Repeat &lt;em&gt;n&lt;/em&gt; times and calculate the product of the successive &lt;em&gt;p&lt;/em&gt;'s. Again each interval is "on average" bisected, but the expected value of the product is not 1/2^&lt;em&gt;n&lt;/em&gt;? What is it?

See also the broken-stick problem.</description>
		<content:encoded><![CDATA[<p>Barry:</p>
<p>It&#8217;s not enough that I make all the mistakes around here? I have to diagnose and explicate them as well? </p>
<p>I&#8217;m working on it. But I&#8217;m busy. I still have a day job. I could use a little help. So let me throw the question back at you.</p>
<p>Suppose I ask you to choose <em>n</em> numbers uniformly at random from the interval [0,1) and calculate their product. You reason that the numbers will have an average value of 1/2, and so the expectation value of the product is 1/2^<em>n</em>.</p>
<p>Now I suggest a slightly different procedure. Again you select a number uniformly at random from the interval [0,1). The selected number &#8212; call it <em>p</em> &#8212; partitions the interval into two subintervals, [0,<em>p</em>) and [p,1). Choose one of these subintervals at random and select a new <em>p</em> from this range. Repeat <em>n</em> times and calculate the product of the successive <em>p</em>&#8217;s. Again each interval is &#8220;on average&#8221; bisected, but the expected value of the product is not 1/2^<em>n</em>? What is it?</p>
<p>See also the broken-stick problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Cipra</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2116</link>
		<dc:creator>Barry Cipra</dc:creator>
		<pubDate>Fri, 17 Apr 2009 13:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2116</guid>
		<description>Brian, I clearly didn't make my point as clearly as I thought!  I wasn't concerned with the small difference between H(N) and ln(N), or with the small difference between your buggy algorithm and Klingemann's optimization.  I just wanted to point out something I think got overlooked:  There is a *big* difference between what you expected the expected running time to be for an outcry algorithm and what the run time actually is.  

In the original post, you gave a perfectly sensible, intuitive explanation why the expected run time should be lg(N) (using "lg" for "log base 2"), namely that each step cuts things in half on average.  But in fact the expected run time is closer to ln(N), which is smaller by a *multiplicative* factor of ln(2) = 0.69.  In other words, the outcry algorithm, whether buggy or not, runs about 30% faster than the parallel "tournament tree" algorithm described in the second paragraph of the post.

So I meant to raise an implicit question:  What's wrong with your perfectly sensible, intuitive explanation for a lg(N) run time?</description>
		<content:encoded><![CDATA[<p>Brian, I clearly didn&#8217;t make my point as clearly as I thought!  I wasn&#8217;t concerned with the small difference between H(N) and ln(N), or with the small difference between your buggy algorithm and Klingemann&#8217;s optimization.  I just wanted to point out something I think got overlooked:  There is a *big* difference between what you expected the expected running time to be for an outcry algorithm and what the run time actually is.  </p>
<p>In the original post, you gave a perfectly sensible, intuitive explanation why the expected run time should be lg(N) (using &#8220;lg&#8221; for &#8220;log base 2&#8243;), namely that each step cuts things in half on average.  But in fact the expected run time is closer to ln(N), which is smaller by a *multiplicative* factor of ln(2) = 0.69.  In other words, the outcry algorithm, whether buggy or not, runs about 30% faster than the parallel &#8220;tournament tree&#8221; algorithm described in the second paragraph of the post.</p>
<p>So I meant to raise an implicit question:  What&#8217;s wrong with your perfectly sensible, intuitive explanation for a lg(N) run time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2115</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Fri, 17 Apr 2009 12:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2115</guid>
		<description>Sorry for the confusion, Barry. I guess two messages that both include the phrase "just to be clear" are almost certain to be muddled. 

I do understand your observation that the number of rounds needed to find the maximum looks *approximately* like ln(N). But I believe that's a coincidence, that the correct expression is H(N) - 1/2. This is close to ln(N) simply because 1/2 is close to &#947;. 

Just to be clear, the reasoning goes as follows. JeffE, in the second comment above, explains where H(N) comes from. The -1/2 term comes from Mario Klingemann's optimization: When only two students are left standing, it doesn't take H(2)=1.5 rounds to identify the larger number. Instead, the N=2 game is over in a single round, no matter what the initial random choice. In my buggy version, the N=2 case takes 1 + 1/2 + 1/4 + ... = 2 rounds.</description>
		<content:encoded><![CDATA[<p>Sorry for the confusion, Barry. I guess two messages that both include the phrase &#8220;just to be clear&#8221; are almost certain to be muddled. </p>
<p>I do understand your observation that the number of rounds needed to find the maximum looks *approximately* like ln(N). But I believe that&#8217;s a coincidence, that the correct expression is H(N) - 1/2. This is close to ln(N) simply because 1/2 is close to &gamma;. </p>
<p>Just to be clear, the reasoning goes as follows. JeffE, in the second comment above, explains where H(N) comes from. The -1/2 term comes from Mario Klingemann&#8217;s optimization: When only two students are left standing, it doesn&#8217;t take H(2)=1.5 rounds to identify the larger number. Instead, the N=2 game is over in a single round, no matter what the initial random choice. In my buggy version, the N=2 case takes 1 + 1/2 + 1/4 + &#8230; = 2 rounds.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Cipra</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2114</link>
		<dc:creator>Barry Cipra</dc:creator>
		<pubDate>Fri, 17 Apr 2009 02:06:36 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2114</guid>
		<description>Brian, no, all I meant to point out is that ln(N) =ln(2)*log_2(N).</description>
		<content:encoded><![CDATA[<p>Brian, no, all I meant to point out is that ln(N) =ln(2)*log_2(N).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2112</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Fri, 17 Apr 2009 00:30:52 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2112</guid>
		<description>So, Barry, just to be clear: What you're suggesting is that the blue curve in the graph above is not y = H(N) &#8211; 1/2 but rather y = H(N) &#8211; &#947; (where &#947; is the Euler-Mascheroni constant, approximately 0.577). (H(N) is asymptotically ln(N) + &#947;.) 

I don't think so. Here are the successive differences between the red and blue curves, for N=2 through N=2048:

0.5, 0.5001935, 0.49465728, 0.49561906, 0.50111556, 0.5011015, 0.49634743, 0.49349594, 0.5049672, 0.5029931, 0.49814177</description>
		<content:encoded><![CDATA[<p>So, Barry, just to be clear: What you&#8217;re suggesting is that the blue curve in the graph above is not y = H(N) &ndash; 1/2 but rather y = H(N) &ndash; &gamma; (where &gamma; is the Euler-Mascheroni constant, approximately 0.577). (H(N) is asymptotically ln(N) + &gamma;.) </p>
<p>I don&#8217;t think so. Here are the successive differences between the red and blue curves, for N=2 through N=2048:</p>
<p>0.5, 0.5001935, 0.49465728, 0.49561906, 0.50111556, 0.5011015, 0.49634743, 0.49349594, 0.5049672, 0.5029931, 0.49814177</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Cipra</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2111</link>
		<dc:creator>Barry Cipra</dc:creator>
		<pubDate>Thu, 16 Apr 2009 22:58:20 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2111</guid>
		<description>Just to be clear, although the outcry algorithm "seems to have an expected running time of log2 N, since each round of eliminations should exclude (on average) half the students still in contention," the analysis shows that, at approximately ln(N), the run time is in fact about 30% faster than that.</description>
		<content:encoded><![CDATA[<p>Just to be clear, although the outcry algorithm &#8220;seems to have an expected running time of log2 N, since each round of eliminations should exclude (on average) half the students still in contention,&#8221; the analysis shows that, at approximately ln(N), the run time is in fact about 30% faster than that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Klingemann</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2109</link>
		<dc:creator>Mario Klingemann</dc:creator>
		<pubDate>Sun, 12 Apr 2009 08:41:43 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2109</guid>
		<description>A small optimization to the outcry method: the student that has shouted his number can also sit down if there is anybody else but him still standing after his shout, since all the other must have numbers higher than his.</description>
		<content:encoded><![CDATA[<p>A small optimization to the outcry method: the student that has shouted his number can also sit down if there is anybody else but him still standing after his shout, since all the other must have numbers higher than his.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Ward</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2108</link>
		<dc:creator>Jim Ward</dc:creator>
		<pubDate>Sat, 11 Apr 2009 15:19:50 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2108</guid>
		<description>I like your stadium idea. Here's a puzzle. As people enter a stadium for a sporting event (Bit Players vs. Bit Twiddlers), they are each given a ticket with a number (positive integer) on it. At halftime, you are to compute the mean, mode, and median. You can use the Jumbotron. Assume the spectators will cooperate with reasonable requests - maybe prizes will be handed out?</description>
		<content:encoded><![CDATA[<p>I like your stadium idea. Here&#8217;s a puzzle. As people enter a stadium for a sporting event (Bit Players vs. Bit Twiddlers), they are each given a ticket with a number (positive integer) on it. At halftime, you are to compute the mean, mode, and median. You can use the Jumbotron. Assume the spectators will cooperate with reasonable requests - maybe prizes will be handed out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Forbes</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2107</link>
		<dc:creator>Michael Forbes</dc:creator>
		<pubDate>Fri, 10 Apr 2009 22:18:09 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2107</guid>
		<description>JeffE:

Ah, your solution is indeed much easier. Thanks!</description>
		<content:encoded><![CDATA[<p>JeffE:</p>
<p>Ah, your solution is indeed much easier. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave P</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2106</link>
		<dc:creator>Dave P</dc:creator>
		<pubDate>Thu, 09 Apr 2009 03:06:59 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2106</guid>
		<description>There are a couple of papers that might interest you depending on, well, your interests. They deal with the following:
- suppose we already have a small-space sequential algorithm (e.g. for sum, the students assign a leader, who reads the numbers one by one and just remembers the sum so far)
- then can we necessarily get a distributed algorithm that works for an arbitrary computation tree?

http://arxiv.org/abs/cs.CC/0611108
http://arxiv.org/abs/0708.0580
The second one is by me :) coming as a byproduct of my master's thesis. In general I found this to be a natural and interesting area whose theory is somewhat underdeveloped.</description>
		<content:encoded><![CDATA[<p>There are a couple of papers that might interest you depending on, well, your interests. They deal with the following:<br />
- suppose we already have a small-space sequential algorithm (e.g. for sum, the students assign a leader, who reads the numbers one by one and just remembers the sum so far)<br />
- then can we necessarily get a distributed algorithm that works for an arbitrary computation tree?</p>
<p><a href="http://arxiv.org/abs/cs.CC/0611108" rel="nofollow">http://arxiv.org/abs/cs.CC/0611108</a><br />
<a href="http://arxiv.org/abs/0708.0580" rel="nofollow">http://arxiv.org/abs/0708.0580</a><br />
The second one is by me :) coming as a byproduct of my master&#8217;s thesis. In general I found this to be a natural and interesting area whose theory is somewhat underdeveloped.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JeffE</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2105</link>
		<dc:creator>JeffE</dc:creator>
		<pubDate>Wed, 08 Apr 2009 22:26:32 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2105</guid>
		<description>Actually, Michael, the analysis of that algorithm is easy if you look at it the right way.  The expected number of rounds is &lt;em&gt;precisely&lt;/em&gt; the Nth harmonic number 1 + 1/2 + 1/3 + ... + 1/N, which is between ln N and ln N + 1. 

The key insight is that the student with the kth smallest number shouts with probability 1/k.  Ignore all but the top k students.  One of the top k students, chosen uniformly at random, shouts first.</description>
		<content:encoded><![CDATA[<p>Actually, Michael, the analysis of that algorithm is easy if you look at it the right way.  The expected number of rounds is <em>precisely</em> the Nth harmonic number 1 + 1/2 + 1/3 + &#8230; + 1/N, which is between ln N and ln N + 1. </p>
<p>The key insight is that the student with the kth smallest number shouts with probability 1/k.  Ignore all but the top k students.  One of the top k students, chosen uniformly at random, shouts first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Forbes</title>
		<link>http://bit-player.org/2009/computing-in-the-classroom#comment-2104</link>
		<dc:creator>Michael Forbes</dc:creator>
		<pubDate>Wed, 08 Apr 2009 18:44:17 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=326#comment-2104</guid>
		<description>In response to the paragraph:

"A variant of the outcry algorithm is easier to analyze: A single student chosen at random calls out his number, and all those students with smaller numbers sit down. Then another student is selected from among those still standing, and the procedure is repeated until only one student remains. This algorithm also seems to have an expected running time of log2 N, since each round of eliminations should exclude (on average) half the students still in contention."

It is true that this algorithm has expected time O(\lg N), but showing this formally is not as easy as one would want.  This is really a probabilistic recurrence relation that, unlike normal recurrence relations, require clever tricks to solve.  This particular recurrence can be solved using techniques from section 1.4 of "Randomized Algorithms", by Motwani and Raghavan.</description>
		<content:encoded><![CDATA[<p>In response to the paragraph:</p>
<p>&#8220;A variant of the outcry algorithm is easier to analyze: A single student chosen at random calls out his number, and all those students with smaller numbers sit down. Then another student is selected from among those still standing, and the procedure is repeated until only one student remains. This algorithm also seems to have an expected running time of log2 N, since each round of eliminations should exclude (on average) half the students still in contention.&#8221;</p>
<p>It is true that this algorithm has expected time O(\lg N), but showing this formally is not as easy as one would want.  This is really a probabilistic recurrence relation that, unlike normal recurrence relations, require clever tricks to solve.  This particular recurrence can be solved using techniques from section 1.4 of &#8220;Randomized Algorithms&#8221;, by Motwani and Raghavan.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

