<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Puzzled Over</title>
	<atom:link href="http://puzzledover.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://puzzledover.wordpress.com</link>
	<description>Maintained by Krish Eswaran</description>
	<lastBuildDate>Sun, 09 Jun 2013 19:34:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='puzzledover.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Puzzled Over</title>
		<link>http://puzzledover.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://puzzledover.wordpress.com/osd.xml" title="Puzzled Over" />
	<atom:link rel='hub' href='http://puzzledover.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Fool Me Once</title>
		<link>http://puzzledover.wordpress.com/2013/06/09/fool-me-once/</link>
		<comments>http://puzzledover.wordpress.com/2013/06/09/fool-me-once/#comments</comments>
		<pubDate>Sun, 09 Jun 2013 19:02:08 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Puzzle]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=221</guid>
		<description><![CDATA[I recently started watching Penn and Teller&#8217;s Fool Me, a show in which magicians try to fool Penn and Teller for a shot to perform in Vegas. After one of the episodes, there was a trick that I couldn&#8217;t even begin &#8230; <a href="http://puzzledover.wordpress.com/2013/06/09/fool-me-once/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=221&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I recently started watching <em>Penn and Teller&#8217;s Fool Me</em>, a show in which magicians try to fool Penn and Teller for a shot to perform in Vegas. After one of the episodes, there was a trick that I couldn&#8217;t even begin to understand, so I went looking for it online. Instead of getting a definitive answer, I found a web page with a bunch of guesses that had degenerated into a flame war. The flame war itself reminded me of <a href="http://xkcd.com/1095/">an xkcd comic</a>, but one of the comments mentioned a separate trick that had fooled Penn and Teller, a supposed mathematical trick performed by Graham Jolley.</p>
<p>The comment didn&#8217;t describe Graham Jolley&#8217;s trick, but it was pretty easy to find and watch. After experimenting with a deck of cards along with a pencil and some scratch paper, I&#8217;ve come up with one possible implementation.</p>
<p><strong>The Effect</strong></p>
<p>The magician takes out a deck of cards and has two participants sit on each side. Participant A is asked to cut about a third of the way into the deck and look at the bottom card. Participant B is asked to cut about half way into the remaining deck and look at the bottom card. The magician then recollects the card stack from Participant A and Participant B, placing them on top of the deck, respectively.</p>
<p>The magician then spreads the deck face down to reveal two jokers facing up. The jokers are taken out, and the magician holds each one close, as if it were transmitting where in the deck to look. In fact, the magician states that the first card will be found <img src='http://s0.wp.com/latex.php?latex=A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A' title='A' class='latex' /> cards into the deck, and the other will be found <img src='http://s0.wp.com/latex.php?latex=B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B' title='B' class='latex' /> cards in. When the magician counts through the deck and sets aside the cards at positions <img src='http://s0.wp.com/latex.php?latex=A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A' title='A' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B' title='B' class='latex' />, they turn out to be the ones for Participant A and Participant B, respectively.</p>
<p><strong>One Possible Method</strong></p>
<p>The method I came up with assumes that Participant A will draw a card roughly 1/3 of the way into the deck, and Participant B draws a card roughly halfway into the remaining deck or roughly 2/3 of the way into the original deck.</p>
<p>Let&#8217;s start with a deck containing <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> cards (not counting the jokers) with the first joker between cards <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=i%2B1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i+1' title='i+1' class='latex' />, and the second between cards <img src='http://s0.wp.com/latex.php?latex=j&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j' title='j' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=j%2B1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j+1' title='j+1' class='latex' />:</p>
<p><img src='http://s0.wp.com/latex.php?latex=1%2C+%5Cldots%2C+i%2C+%5C%7CJOKER%5C%7C%2C+i%2B1%2C+%5Cldots%2C+j%2C+%5C%7CJOKER%5C%7C%2C+j%2B1%2C+%5Cldots%2C+N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='1, &#92;ldots, i, &#92;|JOKER&#92;|, i+1, &#92;ldots, j, &#92;|JOKER&#92;|, j+1, &#92;ldots, N' title='1, &#92;ldots, i, &#92;|JOKER&#92;|, i+1, &#92;ldots, j, &#92;|JOKER&#92;|, j+1, &#92;ldots, N' class='latex' /></p>
<p>We&#8217;ll now proceed with some definitions and assumptions</p>
<p><img src='http://s0.wp.com/latex.php?latex=N_A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_A' title='N_A' class='latex' /> &#8211; the initial position of the card drawn by Participant A<br />
<img src='http://s0.wp.com/latex.php?latex=N_B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_B' title='N_B' class='latex' /> &#8211; the initial position of the card drawn by Participant B<br />
<img src='http://s0.wp.com/latex.php?latex=i+%3C+N_A+%3C+j+%3C+N_B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i &lt; N_A &lt; j &lt; N_B' title='i &lt; N_A &lt; j &lt; N_B' class='latex' /></p>
<p><span style="line-height:1.5;">This would mean that the arrangement of the deck would be as follows:</span></p>
<p><img src='http://s0.wp.com/latex.php?latex=1%2C+%5Cldots%2C+i%2C+%5C%7CJOKER%5C%7C%2C+i%2B1%2C+%5Cldots%2C+N_A%2C+%5Cldots%2C+j%2C+%5C%7CJOKER%5C%7C%2C+j%2B1%2C+%5Cldots%2C+N_B%2C+%5Cldots%2C+N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='1, &#92;ldots, i, &#92;|JOKER&#92;|, i+1, &#92;ldots, N_A, &#92;ldots, j, &#92;|JOKER&#92;|, j+1, &#92;ldots, N_B, &#92;ldots, N' title='1, &#92;ldots, i, &#92;|JOKER&#92;|, i+1, &#92;ldots, N_A, &#92;ldots, j, &#92;|JOKER&#92;|, j+1, &#92;ldots, N_B, &#92;ldots, N' class='latex' /></p>
<p>The magician achieves this by having Participant A get a card from near 1/3 of the way into the deck and placing the first joker well before 1/3 of the way in. Likewise for the second joker (<img src='http://s0.wp.com/latex.php?latex=j+%3D+N%2F2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j = N/2' title='j = N/2' class='latex' /> would be the safest choice).</p>
<p>When Participants A and B replace their stacks on the top of the deck, Participant A goes first, so the order upon this reshuffle looks as follows:</p>
<p><img src='http://s0.wp.com/latex.php?latex=N_%7BA%7D%2B1%2C+%5Cldots%2C+j&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_{A}+1, &#92;ldots, j' title='N_{A}+1, &#92;ldots, j' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=%5C%7CJOKER%5C%7C%2C+j%2B1%2C+%5Cldots%2C+N_B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;|JOKER&#92;|, j+1, &#92;ldots, N_B' title='&#92;|JOKER&#92;|, j+1, &#92;ldots, N_B' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=1%2C+%5Cldots%2C+i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='1, &#92;ldots, i' title='1, &#92;ldots, i' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=%5C%7CJOKER%5C%7C%2C+i%2B1%2C+%5Cldots%2C+N_A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;|JOKER&#92;|, i+1, &#92;ldots, N_A' title='&#92;|JOKER&#92;|, i+1, &#92;ldots, N_A' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=N_%7BB%7D%2B1%2C+%5Cldots%2C+N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_{B}+1, &#92;ldots, N' title='N_{B}+1, &#92;ldots, N' class='latex' /></p>
<p>Note that the first group of cards before the joker</p>
<p><img src='http://s0.wp.com/latex.php?latex=N_%7BA%7D%2B1%2C+%5Cldots%2C+j&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_{A}+1, &#92;ldots, j' title='N_{A}+1, &#92;ldots, j' class='latex' /></p>
<p>contains <img src='http://s0.wp.com/latex.php?latex=j+-+N_A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j - N_A' title='j - N_A' class='latex' /> cards. The second group of cards (between the first and second joker)</p>
<p><img src='http://s0.wp.com/latex.php?latex=j%2B1%2C+%5Cldots%2C+N_B%2C+1%2C+%5Cldots%2C+i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j+1, &#92;ldots, N_B, 1, &#92;ldots, i' title='j+1, &#92;ldots, N_B, 1, &#92;ldots, i' class='latex' />,</p>
<p>contains Participant B&#8217;s card <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' /> positions from the end, and the third group</p>
<p><img src='http://s0.wp.com/latex.php?latex=i%2B1%2C+%5Cldots%2C+N_A%2C+N_%7BB%7D%2B1%2C+%5Cldots%2C+N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i+1, &#92;ldots, N_A, N_{B}+1, &#92;ldots, N' title='i+1, &#92;ldots, N_A, N_{B}+1, &#92;ldots, N' class='latex' /></p>
<p>contains Participant A&#8217;s card <img src='http://s0.wp.com/latex.php?latex=N_A+-+i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_A - i' title='N_A - i' class='latex' /> cards from the beginning.</p>
<p>Thus, by moving the third group between the first and third (this happens when removing the jokers), Participant A&#8217;s card lands <img src='http://s0.wp.com/latex.php?latex=j+-+i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j - i' title='j - i' class='latex' /> positions from the start, and Participant B&#8217;s lands <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' /> cards from the end.</p>
<p>For a standard deck, <img src='http://s0.wp.com/latex.php?latex=N+%3D+52&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 52' title='N = 52' class='latex' />, let <img src='http://s0.wp.com/latex.php?latex=j+%3D+26&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='j = 26' title='j = 26' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=i+%3D+6&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i = 6' title='i = 6' class='latex' />, and Participant A&#8217;s card will land at position 20, and Participant B&#8217;s will land at position 46.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/221/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=221&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2013/06/09/fool-me-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
		<item>
		<title>Complexity and Asymptotes</title>
		<link>http://puzzledover.wordpress.com/2012/05/14/complexity/</link>
		<comments>http://puzzledover.wordpress.com/2012/05/14/complexity/#comments</comments>
		<pubDate>Mon, 14 May 2012 03:30:03 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=202</guid>
		<description><![CDATA[A friend pointed out to me that the statement that the final divide-and-conquer Fibonacci algorithm from the previous post could run in time was a bit misleading. The objection was that I had assumed that the matrix multiplication would not depend on &#8230; <a href="http://puzzledover.wordpress.com/2012/05/14/complexity/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=202&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A friend pointed out to me that the statement that the final divide-and-conquer Fibonacci algorithm from <a href="http://puzzledover.wordpress.com/2012/03/21/code-monkey/">the previous post</a> could run in <img src='http://s0.wp.com/latex.php?latex=O%28%5Clog+N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(&#92;log N)' title='O(&#92;log N)' class='latex' /> time was a bit misleading. The objection was that I had assumed that the matrix multiplication would not depend on <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' />, but that this in fact not the case at all. Namely, if the numbers being added get large, neither the addition nor the multiplication operations of the matrix multiplication cannot be assumed to be constant.</p>
<p>In fact, the earlier analysis of Fibonacci indicated that the value of <img src='http://s0.wp.com/latex.php?latex=%5Ctext%7Bfib%7D%28N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;text{fib}(N)' title='&#92;text{fib}(N)' class='latex' /> could be bounded above and below by <img src='http://s0.wp.com/latex.php?latex=2%5E%7BN%2F2%7D+%3C+%5Ctext%7Bfib%7D%28N%29+%3C+2%5E%7BN%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2^{N/2} &lt; &#92;text{fib}(N) &lt; 2^{N}' title='2^{N/2} &lt; &#92;text{fib}(N) &lt; 2^{N}' class='latex' />, so each of the roughly <img src='http://s0.wp.com/latex.php?latex=%5Clog+N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;log N' title='&#92;log N' class='latex' /> matrix multiplication amounts to 10 multiplication operations and 4 addition operations, which we can bound above as the addition or multiplication on order-of- <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> -bit numbers. By contrast, the iterative algorithm, which I had claimed was linear-time <img src='http://s0.wp.com/latex.php?latex=O%28N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N)' title='O(N)' class='latex' />, requires only one addition operation at each step, resulting in an order of <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> addition operations on order-of- <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> -bit numbers.</p>
<p>If we consider the <a href="http://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations#Arithmetic_functions">complexity of the arithmetic operations</a>, the addition of two <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> bit numbers can be completed in <img src='http://s0.wp.com/latex.php?latex=O%28N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N)' title='O(N)' class='latex' /> time, so the revised complexity of the iterative algorithm becomes <img src='http://s0.wp.com/latex.php?latex=O%28N%5E2%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N^2)' title='O(N^2)' class='latex' />.</p>
<p>For the divide-and-conquer algorithm, we have to consider the complexity of both multiplication operations and addition operations. Suppose we opt for the <a title="Schönhage–Strassen algorithm" href="http://en.wikipedia.org/wiki/Sch%C3%B6nhage%E2%80%93Strassen_algorithm">Schönhage–Strassen algorithm</a>, which has complexity <img src='http://s0.wp.com/latex.php?latex=O%28N+%5Clog+N+%5Clog+%5Clog+N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N &#92;log N &#92;log &#92;log N)' title='O(N &#92;log N &#92;log &#92;log N)' class='latex' />. In this case, the multiplication operations dominate the addition ones, and the revised overall complexity of the algorithm becomes <img src='http://s0.wp.com/latex.php?latex=O%28N+%5Clog%5E2+N+%5Clog+%5Clog+N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N &#92;log^2 N &#92;log &#92;log N)' title='O(N &#92;log^2 N &#92;log &#92;log N)' class='latex' />, which is still faster than the <img src='http://s0.wp.com/latex.php?latex=O%28N%5E2%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N^2)' title='O(N^2)' class='latex' /> iterative algorithm asymptotically. However, I wonder if there is an intermediate region before that asymptotic behavior takes effect in which the iterative approach completes faster.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=202&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2012/05/14/complexity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
		<item>
		<title>Code Monkey</title>
		<link>http://puzzledover.wordpress.com/2012/03/21/code-monkey/</link>
		<comments>http://puzzledover.wordpress.com/2012/03/21/code-monkey/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 05:41:23 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Signal Processing]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=113</guid>
		<description><![CDATA[During my years as a student, I sometimes encountered a disdain in others for writing code. In some cases, the term &#8220;code monkey&#8221; would get used against someone who enjoyed writing code. Something never quite felt right about that term. &#8230; <a href="http://puzzledover.wordpress.com/2012/03/21/code-monkey/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=113&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>During my years as a student, I sometimes encountered a disdain in others for writing code. In some cases, the term &#8220;code monkey&#8221; would get used against someone who enjoyed writing code. Something never quite felt right about that term. Recently, I went to a talk by Donald Knuth, who said something that resonated with me. I am paraphrasing it here: &#8220;Some people say that you truly understand something when you can explain it to a child. I&#8217;d say that you truly understand something when you can explain it to a computer.&#8221;</p>
<p>I took a programming class in high school during which we had to write a program to compute the Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, etc. The way to get the next number in the sequence was to add the previous two numbers in the sequence. In my mind, one that had just digested the idea of <a href="http://en.wikipedia.org/wiki/Recursion">recursion</a>, this was relatively simple to explain to a computer:</p>
<pre>int fib(int N) {
  if (N == 1) return 1;
  if (N == 2) return 2;
  return fib(N - 1) + fib(N - 2);
}</pre>
<p>There was only one problem with my explanation: it would take a computer <strong>exponential time</strong> in <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> to run the code, denoted as <img src='http://s0.wp.com/latex.php?latex=O%282%5EN%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(2^N)' title='O(2^N)' class='latex' />. One way to see it is to notice that the number of calls to the function doubles for every <img src='http://s0.wp.com/latex.php?latex=N+%3E+2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N &gt; 2' title='N &gt; 2' class='latex' />, resulting in a <a href="http://en.wikipedia.org/wiki/Binary_tree">binary tree</a> with the minimum depth to a leaf of <img src='http://s0.wp.com/latex.php?latex=%5Cfrac%7BN%7D%7B2%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;frac{N}{2}' title='&#92;frac{N}{2}' class='latex' /> and a maximum depth of <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' />. Another way to see it is to compile the code and use it to try to compute <img src='http://s0.wp.com/latex.php?latex=%5Ctext%7Bfib%7D%2850%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;text{fib}(50)' title='&#92;text{fib}(50)' class='latex' /> and then wait&#8230; and wait&#8230; and wait.</p>
<div id="attachment_194" class="wp-caption aligncenter" style="width: 1034px"><a href="http://puzzledover.files.wordpress.com/2012/03/img.jpg"><img class="size-large wp-image-194" title="Tree structure of the Fibonacci sequence" src="http://puzzledover.files.wordpress.com/2012/03/img-e1332384450713.jpg?w=1024&#038;h=821" alt="" width="1024" height="821" /></a><p class="wp-caption-text">The Fibonacci sequence grows exponentially, and a naive recursion effectively counts up one-by-one. Thus, such an algorithm grows exponentially, as well.</p></div>
<p>I got tired of waiting, and after studying computer science a while longer, I learned how to explain Fibonacci to a computer that would take <strong>linear time</strong>, i.e. <img src='http://s0.wp.com/latex.php?latex=O%28N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(N)' title='O(N)' class='latex' />:</p>
<pre>int fib(int N) {
  int a = 0;
  int b = 1;
  for (int i = 1; i &lt; N; ++i) {
    int temp = b;
    b += a;
    a = temp;
  }
  return b;
}</pre>
<p>Now I didn&#8217;t have to wait for <img src='http://s0.wp.com/latex.php?latex=%5Ctext%7Bfib%7D%2850%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;text{fib}(50)' title='&#92;text{fib}(50)' class='latex' />, but I would for <img src='http://s0.wp.com/latex.php?latex=%5Ctext%7Bfib%7D%282%5E%7B50%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;text{fib}(2^{50})' title='&#92;text{fib}(2^{50})' class='latex' />. This improved my understanding of the Fibonacci sequence, but at the time, my understanding was quite limited: I hadn&#8217;t taken a linear algebra class yet. Once I had that and some signal processing classes under my belt, I learned that the <a href="http://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression">Fibonacci sequence could be solved in closed-form</a> with a <a href="http://en.wikipedia.org/wiki/Z-transform">z-transform</a>. Alternatively, one could arrive at the closed-form solution by recognizing that the Fibonacci sequence could be represented as the product of an exponentiated matrix with a vector, and all one had to do was decompose that matrix into its <a href="http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors">eigenvalues/eigenvectors</a>:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ctext%7Bfib%7D%28N%2B1%29+%5C%5C+%5Ctext%7Bfib%7D%28N%29+%5Cend%7Barray%7D%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left(&#92;begin{array}{c} &#92;text{fib}(N+1) &#92;&#92; &#92;text{fib}(N) &#92;end{array}&#92;right)' title='&#92;left(&#92;begin{array}{c} &#92;text{fib}(N+1) &#92;&#92; &#92;text{fib}(N) &#92;end{array}&#92;right)' class='latex' /> = <img src='http://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bcc%7D+1+%26+1+%5C%5C+1+%26+0+%5Cend%7Barray%7D%5Cright%29%5EN+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+1+%5C%5C+0+%5Cend%7Barray%7D%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)^N &#92;left(&#92;begin{array}{c} 1 &#92;&#92; 0 &#92;end{array}&#92;right)' title='&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)^N &#92;left(&#92;begin{array}{c} 1 &#92;&#92; 0 &#92;end{array}&#92;right)' class='latex' /></p>
<p>There was still a problem, though. The eigenvalues of the Fibonacci matrix are irrational, and the closed-form solution contains irrational terms, so explaining this to a computer could result in <a href="http://en.wikipedia.org/wiki/Floating_point">floating point</a> errors:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Ctext%7Bfib%7D%28N%29+%3D+%5Cfrac%7B%28%5Cfrac%7B1+%2B+%5Csqrt%7B5%7D%7D%7B2%7D%29%5EN+-+%28%5Cfrac%7B1+-+%5Csqrt%7B5%7D%7D%7B2%7D%29%5EN%7D%7B%5Csqrt%7B5%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;text{fib}(N) = &#92;frac{(&#92;frac{1 + &#92;sqrt{5}}{2})^N - (&#92;frac{1 - &#92;sqrt{5}}{2})^N}{&#92;sqrt{5}}' title='&#92;text{fib}(N) = &#92;frac{(&#92;frac{1 + &#92;sqrt{5}}{2})^N - (&#92;frac{1 - &#92;sqrt{5}}{2})^N}{&#92;sqrt{5}}' class='latex' /></p>
<p>By this time, I was well versed in <a href="http://en.wikipedia.org/wiki/MATLAB">MATLAB</a>, and this wonderful vector-matrix notation could be fed right in, but perhaps I didn&#8217;t understand what was going on as well as I thought.</p>
<p>Some years went by before I took a closer look at the above expression and noticed something: the computation of the closed-form expression involves two quantities that need to be exponentiated, which can be done using a divide-and-conquer algorithm in <img src='http://s0.wp.com/latex.php?latex=O%28%5Clog+N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(&#92;log N)' title='O(&#92;log N)' class='latex' />, i.e. <strong>logarithmic time</strong>. Is there a way to do this that doesn&#8217;t involve floating-point arithmetic?</p>
<p>It turns out the approach is pretty simple: one can apply the same divide-and-conquer technique for exponentiating a number to exponentiating a matrix. The divide step is easy to see when <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> is even:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ctext%7Bfib%7D%28N%2B1%29+%5C%5C+%5Ctext%7Bfib%7D%28N%29+%5Cend%7Barray%7D%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left(&#92;begin{array}{c} &#92;text{fib}(N+1) &#92;&#92; &#92;text{fib}(N) &#92;end{array}&#92;right)' title='&#92;left(&#92;begin{array}{c} &#92;text{fib}(N+1) &#92;&#92; &#92;text{fib}(N) &#92;end{array}&#92;right)' class='latex' /> = <img src='http://s0.wp.com/latex.php?latex=%5Cleft%28%5Cleft%28%5Cbegin%7Barray%7D%7Bcc%7D+1+%26+1+%5C%5C+1+%26+0+%5Cend%7Barray%7D%5Cright%29%5E2%5Cright%29%5E%7BN%2F2%7D+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+1+%5C%5C+0+%5Cend%7Barray%7D%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left(&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)^2&#92;right)^{N/2} &#92;left(&#92;begin{array}{c} 1 &#92;&#92; 0 &#92;end{array}&#92;right)' title='&#92;left(&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)^2&#92;right)^{N/2} &#92;left(&#92;begin{array}{c} 1 &#92;&#92; 0 &#92;end{array}&#92;right)' class='latex' /></p>
<p>If N is odd, the same idea holds:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+%5Ctext%7Bfib%7D%28N%2B1%29+%5C%5C+%5Ctext%7Bfib%7D%28N%29+%5Cend%7Barray%7D%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left(&#92;begin{array}{c} &#92;text{fib}(N+1) &#92;&#92; &#92;text{fib}(N) &#92;end{array}&#92;right)' title='&#92;left(&#92;begin{array}{c} &#92;text{fib}(N+1) &#92;&#92; &#92;text{fib}(N) &#92;end{array}&#92;right)' class='latex' /> = <img src='http://s0.wp.com/latex.php?latex=%5Cleft%28%5Cbegin%7Barray%7D%7Bcc%7D+1+%26+1+%5C%5C+1+%26+0+%5Cend%7Barray%7D%5Cright%29%5Cleft%28%5Cleft%28%5Cbegin%7Barray%7D%7Bcc%7D+1+%26+1+%5C%5C+1+%26+0+%5Cend%7Barray%7D%5Cright%29%5E2%5Cright%29%5E%7B%28N-1%29%2F2%7D+%5Cleft%28%5Cbegin%7Barray%7D%7Bc%7D+1+%5C%5C+0+%5Cend%7Barray%7D%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)&#92;left(&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)^2&#92;right)^{(N-1)/2} &#92;left(&#92;begin{array}{c} 1 &#92;&#92; 0 &#92;end{array}&#92;right)' title='&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)&#92;left(&#92;left(&#92;begin{array}{cc} 1 &amp; 1 &#92;&#92; 1 &amp; 0 &#92;end{array}&#92;right)^2&#92;right)^{(N-1)/2} &#92;left(&#92;begin{array}{c} 1 &#92;&#92; 0 &#92;end{array}&#92;right)' class='latex' /></p>
<p>Given this, it isn&#8217;t too hard to explain to a computer how to compute the Fibonacci sequence in <img src='http://s0.wp.com/latex.php?latex=O%28%5Clog+N%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='O(&#92;log N)' title='O(&#92;log N)' class='latex' /> time without resorting to floating-point arithmetic:</p>
<pre>int fib(int N) {
  Matrix&lt;int&gt; m(1,1,1,0);
  Vector&lt;int&gt; v(1,0);
  Vector&lt;int&gt; v = fib_helper(N, m, v);
  return v[0];
}
Vector fib_helper(int N, Matrix&lt;int&gt; m, Vector&lt;int&gt; v) {
  // Base case
  if (N == 1) {
    // Multiples the matrix and the vector.
    return MultiplyMatrixVector(m, v);
  }
  // Even case
  if (N % 2 == 0) {
    // Squares the matrix.
    return fib_helper(N / 2, SquareMatrix(m), v);
  }
  // Odd case
  return MultiplyMatrixVector(
      m, fib_helper(N - 1, m, v));
}</pre>
<p>Are there any cases in which programming has helped you understand a concept better? Are there any cases in which understanding a concept has made you a better programmer?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=113&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2012/03/21/code-monkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>

		<media:content url="http://puzzledover.files.wordpress.com/2012/03/img-e1332384450713.jpg?w=1024" medium="image">
			<media:title type="html">Tree structure of the Fibonacci sequence</media:title>
		</media:content>
	</item>
		<item>
		<title>Voting Paradox</title>
		<link>http://puzzledover.wordpress.com/2010/10/16/voting-paradox/</link>
		<comments>http://puzzledover.wordpress.com/2010/10/16/voting-paradox/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 23:16:04 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Papers]]></category>
		<category><![CDATA[Puzzle]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=104</guid>
		<description><![CDATA[Inspired by the upcoming elections, I spent a little time yesterday trying to think up an example in which people could potentially have logically consistent beliefs individually but as a whole produce logically inconsistent outcomes. The result of that effort &#8230; <a href="http://puzzledover.wordpress.com/2010/10/16/voting-paradox/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=104&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Inspired by the upcoming elections, I spent a little time yesterday trying to think up an example in which people could potentially have logically consistent beliefs individually but as a whole produce logically inconsistent outcomes. The result of that effort follows.</p>
<p>It&#8217;s election time, and there are three propositions on the ballot to spend a budget surplus. Proposition 1 is to increase funding for education. Proposition 2 is to increase funding for the healthcare. However, if both Propositions 1 and 2 pass, the tax rate needs to increase to 8% to avoid a budget shortfall. Proposition 3 is designed to do just this.</p>
<p>There are three voters in the town. Alice is for education only, so she supports Proposition 1 but not 2 or 3. Bob is for healthcare only, so he supports Proposition 2 but not 1 or 3. Cindy wants both education and healthcare, so she supports Propositions 1, 2, and 3.  While everyone believes in something logically consistent, in this scenario, both Propositions 1 and 2 pass, but Proposition 3, the tax increase, is defeated, leading to a budget shortfall.</p>
<p>I posed the problem above to <a href="http://math.berkeley.edu/~jbledin/Site/MainPage.html">Justin Bledin</a>, a graduate student in the Logic Group at UC Berkeley, to find out if the idea made sense or not.</p>
<p>&#8220;If you&#8217;d stumbled upon this ten years ago, it would have made a nice paper,&#8221; Justin responded before pointing me to the judgment aggregation paradox, something that he had come across in a decision theory seminar.</p>
<p>In 2002, <a href="http://personal.lse.ac.uk/list/research.htm">Christian List</a> and <a href="http://www.princeton.edu/~ppettit/papers.htm">Philip Pettit</a>&#8216;s &#8220;Aggregating Sets of Judgments: An Impossibility Result&#8221; was published in <em>Economics and Philosophy</em>. The paper starts with an example similar in flavor to the one above and goes on to prove that a voting function will produce logically inconsistent output for certain logically consistent profile of inputs if the voting function satisfies the following three conditions:</p>
<ol>
<li>The voting function should accept any individual&#8217;s voting profile if it satisfies certain conditions for logical consistency.</li>
<li>The output of the voting function should be the same for any permutation of the individual voting profiles.</li>
<li>If two propositions have the same votes in favor, then their outcome should be the same.</li>
</ol>
<p>The paper concludes with strategies that could produce one a consistent voting function if one of the rules were relaxed. One idea that comes out of the second theorem of the paper is a median-based voting method, so long as there is a way to order individual voting profiles. It would be interesting to think about how one might construct such voting systems in practice.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=104&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2010/10/16/voting-paradox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
		<item>
		<title>Walking Downhill</title>
		<link>http://puzzledover.wordpress.com/2010/07/12/walking-downhill/</link>
		<comments>http://puzzledover.wordpress.com/2010/07/12/walking-downhill/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 05:25:54 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Information Theory]]></category>
		<category><![CDATA[Papers]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=69</guid>
		<description><![CDATA[The problem asks you to show that . If , then the solution is quite easy. Set the gradient equal to zero and solve the system of equations for . Since the function is convex, this is the minimum point, and &#8230; <a href="http://puzzledover.wordpress.com/2010/07/12/walking-downhill/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=69&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The problem asks you to show that <img src='http://s0.wp.com/latex.php?latex=f%28%5Cvec%7Bx%7D%29+%5Cgeq+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(&#92;vec{x}) &#92;geq 0' title='f(&#92;vec{x}) &#92;geq 0' class='latex' />. If <img src='http://s0.wp.com/latex.php?latex=f%28x_1%2Cx_2%29+%3D+x_1%5E2+%2B+x_2%5E2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(x_1,x_2) = x_1^2 + x_2^2' title='f(x_1,x_2) = x_1^2 + x_2^2' class='latex' />, then the solution is quite easy. Set the gradient equal to zero and solve the system of equations for <img src='http://s0.wp.com/latex.php?latex=%5Cvec%7Bx%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;vec{x}' title='&#92;vec{x}' class='latex' />. Since the function is convex, this is the minimum point, and the answer is simply</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=f%28%5Cvec%7Bx%7D%29+%5Cgeq+f%280%2C0%29+%3D+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(&#92;vec{x}) &#92;geq f(0,0) = 0' title='f(&#92;vec{x}) &#92;geq f(0,0) = 0' class='latex' />.</p>
<p>However, one can add a wrinkle to this problem to make it more of a challenge. If the <img src='http://s0.wp.com/latex.php?latex=f%28x_1%2C+x_2%29+%3D+%5Clog+%281+%2B+x_1%5E2+%2B+x_2%5E2%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(x_1, x_2) = &#92;log (1 + x_1^2 + x_2^2)' title='f(x_1, x_2) = &#92;log (1 + x_1^2 + x_2^2)' class='latex' />, then we no longer have a convex function. However, it can be shown that this function is minimized at <img src='http://s0.wp.com/latex.php?latex=%5Cvec%7Bx%7D+%3D+%5Cvec%7B0%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;vec{x} = &#92;vec{0}' title='&#92;vec{x} = &#92;vec{0}' class='latex' />, and there is a surprisingly general argument that works and has been used to considerable effect in the literature.</p>
<p>The argument can be summarized intuitively as follows: show that from any point, there is a downward path to the minimum. For instance, in the above problem, one can define <img src='http://s0.wp.com/latex.php?latex=g%28t%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g(t)' title='g(t)' class='latex' /> as follows:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=g%28t%29+%3D+f%28x_1+%5Ccdot+%281+-+t%29%2C+x_2+%5Ccdot+%281+-+t%29%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g(t) = f(x_1 &#92;cdot (1 - t), x_2 &#92;cdot (1 - t))' title='g(t) = f(x_1 &#92;cdot (1 - t), x_2 &#92;cdot (1 - t))' class='latex' />.</p>
<p style="text-align:left;">Then, it is straightforward to show that over the interval <img src='http://s0.wp.com/latex.php?latex=%5B0%2C1%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='[0,1]' title='[0,1]' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=g%27%28t%29+%5Cleq+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g&#039;(t) &#92;leq 0' title='g&#039;(t) &#92;leq 0' class='latex' /> for either choice of <img src='http://s0.wp.com/latex.php?latex=f%28x_1%2C+x_2%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(x_1, x_2)' title='f(x_1, x_2)' class='latex' /> above. Furthermore, <img src='http://s0.wp.com/latex.php?latex=g%280%29+%3D+f%28x_1%2C+x_2%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g(0) = f(x_1, x_2)' title='g(0) = f(x_1, x_2)' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=g%281%29+%3D+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g(1) = 0' title='g(1) = 0' class='latex' />, so we can conclude that <img src='http://s0.wp.com/latex.php?latex=f%28%5Cvec%7Bx%7D%29+%5Cgeq+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(&#92;vec{x}) &#92;geq 0' title='f(&#92;vec{x}) &#92;geq 0' class='latex' />.</p>
<p style="text-align:left;"><strong>Entropy Power Inequality</strong></p>
<p style="text-align:left;">As mentioned before, this type of argument has proved to be potent in papers. One of the first places I encountered the argument was in the proof of the <a href="http://en.wikipedia.org/wiki/Entropy_power_inequality">entropy power inequality</a>. There are several equivalent statements of the result (see e.g. <a href="http://dx.doi.org/10.1109%2F18.104312">Dembo et al. 1991</a>), one of which is the following. Given two independent random variables <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X' title='X' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=Y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y' title='Y' class='latex' /> with differential entropies <em>h(X)</em> and <em>h(Y)</em>, respectively, then</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=h%28X+%2B+Y%29+%5Cgeq+h%28%5Ctilde%7BX%7D+%2B+%5Ctilde%7BY%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='h(X + Y) &#92;geq h(&#92;tilde{X} + &#92;tilde{Y})' title='h(X + Y) &#92;geq h(&#92;tilde{X} + &#92;tilde{Y})' class='latex' />,</p>
<p style="text-align:left;">where <img src='http://s0.wp.com/latex.php?latex=%5Ctilde%7BX%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;tilde{X}' title='&#92;tilde{X}' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Ctilde%7BY%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;tilde{Y}' title='&#92;tilde{Y}' class='latex' /> are independent Gaussian random variables with the same differential entropies as <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X' title='X' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=Y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y' title='Y' class='latex' />, respectively. The entropy power inequality has been used to prove converses for Gaussian broadcast channels and the quadratic Gaussian CEO problem.</p>
<p style="text-align:left;">The proof essentially involves transforming the distributions of <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X' title='X' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=Y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y' title='Y' class='latex' /> to the distributions of <img src='http://s0.wp.com/latex.php?latex=%5Ctilde%7BX%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;tilde{X}' title='&#92;tilde{X}' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Ctilde%7BY%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;tilde{Y}' title='&#92;tilde{Y}' class='latex' /> along a path that does not increase the differential entropy of the sum.</p>
<p style="text-align:left;"><strong>Parameter Redundancy of the KT-Estimator</strong></p>
<p style="text-align:left;">I&#8217;ll end with another use of the argument found in <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.352">Willems, Shtarkov, and Tjalken&#8217;s &#8220;The Context-Tree Weighting Method: Basic Properties&#8221; from the May 1995 issue of the <em>IEEE Transactions on Information Theory</em></a>. Many of the results that follow from the paper make use of the Krichevski-Trofimov (KT) estimator, which approximates the probability distribution of a binary sequence based on the number of ones and zeroes. With the above argument, one can show that the parameter redundancy of a KT-estimator can be uniformly bounded. To state this mathematically, first let <img src='http://s0.wp.com/latex.php?latex=P_e+%28a%2C+b%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='P_e (a, b)' title='P_e (a, b)' class='latex' /> represent the KT-estimator for a sequence with <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /> ones and <img src='http://s0.wp.com/latex.php?latex=b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b' title='b' class='latex' /> zeroes. Also note that for a Bernoulli sequence with parameter <img src='http://s0.wp.com/latex.php?latex=%5Ctheta&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta' title='&#92;theta' class='latex' />, the probability the sequence has <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /> ones and <img src='http://s0.wp.com/latex.php?latex=b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b' title='b' class='latex' /> zeroes is <img src='http://s0.wp.com/latex.php?latex=%281+-+%5Ctheta%29%5Ea+%5Ccdot+%5Ctheta%5Eb&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(1 - &#92;theta)^a &#92;cdot &#92;theta^b' title='(1 - &#92;theta)^a &#92;cdot &#92;theta^b' class='latex' />. The result states that for all values of <img src='http://s0.wp.com/latex.php?latex=%5Ctheta&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta' title='&#92;theta' class='latex' />,</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Clog+%5Cfrac%7B%281+-+%5Ctheta%29%5Ea+%5Ccdot+%5Ctheta%5Eb%7D%7BP_e+%28a%2C+b%29%7D+%5Cleq+%5Cfrac%7B1%7D%7B2%7D+%5Clog+%28a+%2B+b%29+%2B+1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;log &#92;frac{(1 - &#92;theta)^a &#92;cdot &#92;theta^b}{P_e (a, b)} &#92;leq &#92;frac{1}{2} &#92;log (a + b) + 1' title='&#92;log &#92;frac{(1 - &#92;theta)^a &#92;cdot &#92;theta^b}{P_e (a, b)} &#92;leq &#92;frac{1}{2} &#92;log (a + b) + 1' class='latex' />.</p>
<p style="text-align:left;">Note that the upper bound does not depend on <img src='http://s0.wp.com/latex.php?latex=%5Ctheta&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta' title='&#92;theta' class='latex' />. This result is a key component for the authors to show that the redundancy of the context-tree weighting method is small and thereby demonstrate they have a compelling strategy for universal source coding.</p>
<p style="text-align:left;">The uniform bound above follows from a lower bound on the KT-estimator:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=P_e+%28a%2C+b%29+%5Cgeq+%5Cfrac%7B1%7D%7B2%7D+%5Ccdot+%5Cfrac%7B1%7D%7B%5Csqrt%7Ba+%2B+b%7D%7D+%5Ccdot+%28%5Cfrac%7Ba%7D%7Ba%2Bb%7D%29%5Ea+%5Ccdot+%28%5Cfrac%7Bb%7D%7Ba%2Bb%7D%29%5Eb&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='P_e (a, b) &#92;geq &#92;frac{1}{2} &#92;cdot &#92;frac{1}{&#92;sqrt{a + b}} &#92;cdot (&#92;frac{a}{a+b})^a &#92;cdot (&#92;frac{b}{a+b})^b' title='P_e (a, b) &#92;geq &#92;frac{1}{2} &#92;cdot &#92;frac{1}{&#92;sqrt{a + b}} &#92;cdot (&#92;frac{a}{a+b})^a &#92;cdot (&#92;frac{b}{a+b})^b' class='latex' />.</p>
<p style="text-align:left;">To prove the result, the authors define</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5CDelta%28a%2C+b%29+%3D+%5Cfrac%7BP_e+%28a%2C+b%29%7D%7B%5Cfrac%7B1%7D%7B%5Csqrt%7Ba+%2B+b%7D%7D+%5Ccdot+%28%5Cfrac%7Ba%7D%7Ba%2Bb%7D%29%5Ea+%5Ccdot+%28%5Cfrac%7Bb%7D%7Ba%2Bb%7D%29%5Eb%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;Delta(a, b) = &#92;frac{P_e (a, b)}{&#92;frac{1}{&#92;sqrt{a + b}} &#92;cdot (&#92;frac{a}{a+b})^a &#92;cdot (&#92;frac{b}{a+b})^b}' title='&#92;Delta(a, b) = &#92;frac{P_e (a, b)}{&#92;frac{1}{&#92;sqrt{a + b}} &#92;cdot (&#92;frac{a}{a+b})^a &#92;cdot (&#92;frac{b}{a+b})^b}' class='latex' /></p>
<p style="text-align:left;">and find a downward path to show that <img src='http://s0.wp.com/latex.php?latex=%5CDelta%28a%2C+b%29+%5Cgeq+%5CDelta%281%2C0%29+%3D+%5CDelta%280%2C1%29+%3D+%5Cfrac%7B1%7D%7B2%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;Delta(a, b) &#92;geq &#92;Delta(1,0) = &#92;Delta(0,1) = &#92;frac{1}{2}' title='&#92;Delta(a, b) &#92;geq &#92;Delta(1,0) = &#92;Delta(0,1) = &#92;frac{1}{2}' class='latex' />.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=69&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2010/07/12/walking-downhill/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
		<item>
		<title>4 Prisoners</title>
		<link>http://puzzledover.wordpress.com/2010/07/06/4-prisoners/</link>
		<comments>http://puzzledover.wordpress.com/2010/07/06/4-prisoners/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 19:20:47 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Probability]]></category>
		<category><![CDATA[Puzzle]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=55</guid>
		<description><![CDATA[The end of the 100 Prisoners post asked if there is a way to show that there does not exist a strategy that meets the coupon collector lower bound for release when there are prisoners. Let&#8217;s first establish strategies for &#8230; <a href="http://puzzledover.wordpress.com/2010/07/06/4-prisoners/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=55&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The end of the <a href="http://puzzledover.wordpress.com/2010/06/25/100-prisoners/">100 Prisoners post</a> asked if there is a way to show that there does not exist a strategy that meets the coupon collector lower bound for release when there are <img src='http://s0.wp.com/latex.php?latex=N+%3E+3&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N &gt; 3' title='N &gt; 3' class='latex' /> prisoners.</p>
<p>Let&#8217;s first establish strategies for <img src='http://s0.wp.com/latex.php?latex=N+%5Cleq+3&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N &#92;leq 3' title='N &#92;leq 3' class='latex' />. Note that for <img src='http://s0.wp.com/latex.php?latex=N+%3D+1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 1' title='N = 1' class='latex' />, the prisoner can declare victory on the first day, which trivially meets the coupon collector lower bound. Similarly, for <img src='http://s0.wp.com/latex.php?latex=N+%3D+2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 2' title='N = 2' class='latex' />, the first time a new prisoner enters after the first day, the prisoner can declare victory since there is only one other prisoner, who entered on the first day. Again, this trivially meets the coupon collector bound.</p>
<p>For <img src='http://s0.wp.com/latex.php?latex=N+%3D+3&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 3' title='N = 3' class='latex' />, we actually need to use the light switch. On day 1, the first prisoner turns the light switch off. The next new prisoner (second prisoner) to enter turns the light switch on. The next new prisoner (third prisoner) to see the light switch on declares victory. Once again, this meets the coupon collector lower bound.</p>
<p>Why don&#8217;t we have luck for <img src='http://s0.wp.com/latex.php?latex=N+%3D+4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 4' title='N = 4' class='latex' />? We can arrive at it by contradiction: suppose there is a strategy that meets the coupon collector lower bound. Note that this requires the fourth prisoner to be able to determine based on the time of first entry and by looking at the light bulb whether or not he is the fourth prisoner. Without the light switch, all a new prisoner knows for any time <img src='http://s0.wp.com/latex.php?latex=t+%5Cgeq+4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='t &#92;geq 4' title='t &#92;geq 4' class='latex' /> days is that he is not the first prisoner. Thus, if such a strategy should work, for <img src='http://s0.wp.com/latex.php?latex=t+%5Cgeq+4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='t &#92;geq 4' title='t &#92;geq 4' class='latex' />, the light switch should uniquely identify whether or not three other prisoners have visited the room or not.</p>
<p>Without loss of generality, for <img src='http://s0.wp.com/latex.php?latex=t+%5Cgeq+4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='t &#92;geq 4' title='t &#92;geq 4' class='latex' />, the switch will be on if and only if three of the prisoners have visited the room already. Suppose a prisoner enters the room for the first time on some day <img src='http://s0.wp.com/latex.php?latex=t+%5Cgeq+4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='t &#92;geq 4' title='t &#92;geq 4' class='latex' />. If the light switch is off, then the prisoner must set the switch for the next day. However, the only information available to the prisoner is <img src='http://s0.wp.com/latex.php?latex=t&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='t' title='t' class='latex' /> and the position of the switch, which indicates that either one or two prisoners have visited the room previously. If the prisoner sets the switch to on, and only one prisoner had visited the room before, the switch was set incorrectly. On the other hand, if the prisoner sets the switch to off, and two prisoners had visited the room before, the switch was also set incorrectly. Thus, we have arrived at a contradiction, and no strategy can achieve the coupon collector lower bound. Calculating an expected lower bound based on this argument and extending the argument to all <img src='http://s0.wp.com/latex.php?latex=N+%3E+3&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N &gt; 3' title='N &gt; 3' class='latex' /> are left as exercises.</p>
<p>While the above argument indicates that the coupon collector lower bound is not tight for <img src='http://s0.wp.com/latex.php?latex=N+%3D+4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 4' title='N = 4' class='latex' />, it does not say whether the strategy given in the previous post is the best one can do. In fact, it is not, and what follows is a better strategy. Now, the light switch is used to indicate whether there have been an even or odd number of visitors to the room. The first visitor to the room switches it on, and on any prisoner&#8217;s first visit to the room thereafter changes the state of light switch:</p>
<p>1st prisoner changes the switch to <strong><span style="color:#008000;">&#8216;on&#8217;</span></strong><br />
2nd prisoner enters for the first time with the switch <strong><span style="color:#800000;">&#8216;on&#8217;</span></strong> and changes it to <strong><span style="color:#008000;">&#8216;off&#8217;</span></strong><br />
3rd prisoner enters for the first time with the switch <strong><span style="color:#800000;">&#8216;off&#8217;</span></strong> and changes it to <strong><span style="color:#008000;">&#8216;on&#8217;</span></strong><br />
4th prisoner enters for the first time with the switch <strong><span style="color:#800000;">&#8216;on&#8217;</span></strong> and changes it to <strong><span style="color:#008000;">&#8216;off&#8217;</span></strong></p>
<p>Note that since the third prisoner is only person to see the light switch off on his first time in the room, he can uniquely identify that there is only one prisoner left, and the next time he enters the room and sees the switch is off, he can declare victory. Likewise, if the first or second prisoner reenter the room after the third prisoner and before the fourth prisoner, then he can also figure out that there is only one prisoner left and can declare victory the next time he sees the switch off. It turns out the probability that both of them visit, which results in an expected time to release of</p>
<p style="text-align:center;">4/3 + <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}' title='&#92;mathbb{E}' class='latex' /> [coupon collector],</p>
<p>is 1/3; the probability only one of then visits, which results in an expected time to release of</p>
<p style="text-align:center;">2 + <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}' title='&#92;mathbb{E}' class='latex' /> [coupon collector],</p>
<p>is 1/3; and the probability that neither visits, which results in an expected time to release of</p>
<p style="text-align:center;">4 + <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}' title='&#92;mathbb{E}' class='latex' /> [coupon collector],</p>
<p>is 1/3. Thus, the expected time to release is <img src='http://s0.wp.com/latex.php?latex=%5Cfrac%7B22%7D%7B9%7D+%2B+%5Cmathbb%7BE%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;frac{22}{9} + &#92;mathbb{E}' title='&#92;frac{22}{9} + &#92;mathbb{E}' class='latex' /> [coupon collector], where <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}' title='&#92;mathbb{E}' class='latex' /> [coupon collector] <img src='http://s0.wp.com/latex.php?latex=%3D+%5Cfrac%7B25%7D%7B3%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='= &#92;frac{25}{3}' title='= &#92;frac{25}{3}' class='latex' />. This drops the expected time after coupon collector from <img src='http://s0.wp.com/latex.php?latex=12&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='12' title='12' class='latex' /> to about <img src='http://s0.wp.com/latex.php?latex=2.4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2.4' title='2.4' class='latex' />. Of course, we are taking advantage of the the fact that the number of prisoners is so small. I suspect it will be more difficult to make such pronounced improvements over the earlier strategy for larger <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' />.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=55&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2010/07/06/4-prisoners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
		<item>
		<title>Shannon Meets Shannon</title>
		<link>http://puzzledover.wordpress.com/2010/07/06/shannon-meets-shannon/</link>
		<comments>http://puzzledover.wordpress.com/2010/07/06/shannon-meets-shannon/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 06:41:13 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Information Theory]]></category>
		<category><![CDATA[Signal Processing]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=38</guid>
		<description><![CDATA[He&#8217;s met almost everyone else: Wiener, Bode, Bellman, Carnot, Tesla, Marconi, and of course, Shortz. Bad jokes aside, in an attempt to understand the inverse water filling solution from rate-distortion theory better, I put together some rough notes attempting to connect it and the sampling &#8230; <a href="http://puzzledover.wordpress.com/2010/07/06/shannon-meets-shannon/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=38&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>He&#8217;s met almost everyone else: <a href="http://arxiv.org/abs/cs/0409011">Wiener</a>, <a href="http://cat.inist.fr/?aModele=afficheN&amp;cpsidt=16145882">Bode</a>, <a href="http://www.stanford.edu/~adlakha/ITMANET/ITMANET_Publications/meyn_cdc08.pdf">Bellman</a>, <a href="http://iopscience.iop.org/0295-5075/85/1/10006">Carnot</a>, <a href="http://www.eecs.berkeley.edu/~pulkit/papers/WirelessInfoAndPower.pdf">Tesla</a>, <a href="http://slidefinder.net/m/modern_wireless_communication_when_shannon/6887829">Marconi</a>, and of course, <a href="http://portal.acm.org/citation.cfm?id=1358262.1358265">Shortz</a>. Bad jokes aside, in an attempt to understand the <a href="http://en.wikipedia.org/wiki/Rate%E2%80%93distortion_theory">inverse water filling solution from rate-distortion theory</a> better, I put together some rough notes attempting to connect it and the <a href="http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem">sampling theorem</a>. It&#8217;s kind of old school but makes an interesting exercise for students of information theory and signal processing. There are almost certainly places in the notes where the descriptions could be stated better, and I haven&#8217;t thoroughly scrubbed it for typos, so any feedback is both welcomed and encouraged.</p>
<p><a href="http://puzzledover.files.wordpress.com/2010/07/sampling-inverse-water-filling.pdf">sampling-inverse-water-filling v1.0</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=38&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2010/07/06/shannon-meets-shannon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
		<item>
		<title>100 Prisoners</title>
		<link>http://puzzledover.wordpress.com/2010/06/25/100-prisoners/</link>
		<comments>http://puzzledover.wordpress.com/2010/06/25/100-prisoners/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 03:58:16 +0000</pubDate>
		<dc:creator>K</dc:creator>
				<category><![CDATA[Probability]]></category>
		<category><![CDATA[Puzzle]]></category>

		<guid isPermaLink="false">http://puzzledover.wordpress.com/?p=17</guid>
		<description><![CDATA[100 prisoners are condemned to life in prison, or so they think. One day the warden assembles all of the prisoners together and offers them a deal: &#8220;Starting tomorrow, I will select a prisoner at random every day and send &#8230; <a href="http://puzzledover.wordpress.com/2010/06/25/100-prisoners/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=17&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>100 prisoners are condemned to life in prison, or so they think. One day the warden assembles all of the prisoners together and offers them a deal: &#8220;Starting tomorrow, I will select a prisoner at random every day and send him to a room with a lightbulb and switch. The prisoner may choose to turn the light on or off and must then leave. Now, here&#8217;s the deal: if, after visiting the room, a prisoner is convinced that all other prisoners have visited the room at least once, he may say so. If he is right, you will all be freed. If he is wrong, you will all be executed. After tonight, you will not be able to see or contact each other ever again, so devise a strategy now.&#8221; Morbidness aside, what strategy can the prisoners devise that guarantees their freedom?</p>
<p>After a friend first posed it to me, I&#8217;ve reasked this to several people over the years. Most who come up with a solution leave it that, but my uncle was not one of them.</p>
<p>&#8220;It&#8217;s going to take them too long to get out,&#8221; he noted. I sympathized, but somehow I wasn&#8217;t convinced there was a better solution, either.</p>
<p>Before getting to that solution and the time to release, how long would it actually take for the all the prisoners to visit the room at least once? The answer lies in the coupon collector&#8217;s problem. Given <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> prisoners, the time <img src='http://s0.wp.com/latex.php?latex=T&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T' title='T' class='latex' /> for all of them to visit the room at least once can be expressed as the sum of geometric random variables <img src='http://s0.wp.com/latex.php?latex=T+%3D+T_1+%2B+T_2+%2B+%5Ccdots+T_N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T = T_1 + T_2 + &#92;cdots T_N' title='T = T_1 + T_2 + &#92;cdots T_N' class='latex' />, where <img src='http://s0.wp.com/latex.php?latex=T_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T_i' title='T_i' class='latex' /> is the time for <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' />th new person to enter the room after the <img src='http://s0.wp.com/latex.php?latex=i-1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i-1' title='i-1' class='latex' />th new person has been there. By linearity of expectation, the expected time for all prisoners to visit the cell at least once can then be expressed as follows:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D%5BT%5D+%3D+%5Csum_%7Bi%3D1%7D%5EN+%5Cmathbb%7BE%7D%5BT_i%5D+%3D+%5Csum_%7Bi%3D1%7D%5EN+%5Cfrac%7BN%7D%7BN%2B1-i%7D+%3D+N+%5Ccdot+%5Csum_%7Bi%3D1%7D%5EN+%5Cfrac%7B1%7D%7Bi%7D+%7E.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}[T] = &#92;sum_{i=1}^N &#92;mathbb{E}[T_i] = &#92;sum_{i=1}^N &#92;frac{N}{N+1-i} = N &#92;cdot &#92;sum_{i=1}^N &#92;frac{1}{i} ~.' title='&#92;mathbb{E}[T] = &#92;sum_{i=1}^N &#92;mathbb{E}[T_i] = &#92;sum_{i=1}^N &#92;frac{N}{N+1-i} = N &#92;cdot &#92;sum_{i=1}^N &#92;frac{1}{i} ~.' class='latex' /></p>
<p>For <img src='http://s0.wp.com/latex.php?latex=N+%3D+100&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 100' title='N = 100' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D%5BT%5D+%5Capprox+519&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}[T] &#92;approx 519' title='&#92;mathbb{E}[T] &#92;approx 519' class='latex' /> days, so the expected time for everyone to visit the room at least once would be less than two years.</p>
<p>Now what about for our solution? First, what was our solution? It works as follows. The person who enters on the first day becomes the monitor, who is the only one allowed to turn the light switch off. Everyone else is allowed either to turn the switch on or leave it as is. The goal is for the monitor to count the number of people who have visited the room at least once by the number of times he enters the room and the switch is on. To do this, the remaining prisoners follow the following protocol: if the prisoner has never turned the switch on and sees it off, he turns it on; otherwise, he leaves it as is. This protocol prevents the monitor from overcounting the number of prisoners who have. Thus, once the monitor has entered the room with the switch on <img src='http://s0.wp.com/latex.php?latex=N-1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N-1' title='N-1' class='latex' /> times (the monitor can ignore his first visit and automatically count himself), he can claim with certainty that each prisoner has visited the room at least once. However, once a switch is turned on, prisoners who have yet to visit the room must wait until the monitor visits the room again before they are allowed to indicate their entry, thereby delaying the monitors final announcement.</p>
<p>How long exactly does it take? Again, we can proceed by a sum of geometric random variables. Let <img src='http://s0.wp.com/latex.php?latex=U&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='U' title='U' class='latex' /> be the day the monitor announces every prisoner has been to the room at least once, which we express as the sum</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=U+%3D+T_1+%2B+V_1+%2B+M_1+%2B+V_2+%2B+M_2+%2B+%5Ccdots+%2B+V_%7BN-1%7D+%2B+M_%7BN-1%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='U = T_1 + V_1 + M_1 + V_2 + M_2 + &#92;cdots + V_{N-1} + M_{N-1}' title='U = T_1 + V_1 + M_1 + V_2 + M_2 + &#92;cdots + V_{N-1} + M_{N-1}' class='latex' />.</p>
<p>Here, <img src='http://s0.wp.com/latex.php?latex=M_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='M_i' title='M_i' class='latex' /> represents number of days between the <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' />th time light is turned on, and the monitor&#8217;s next visit to the room. This is a geometric random variable with expectation <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D%5BM_i%5D+%3D+N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}[M_i] = N' title='&#92;mathbb{E}[M_i] = N' class='latex' />. Similarly, <img src='http://s0.wp.com/latex.php?latex=V_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='V_i' title='V_i' class='latex' /> represents the number of days between the monitor&#8217;s last visit and the <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' />th prisoner that can turn on the switch for the first time. This is a geometric random variable with expectation <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D%5BM_i%5D+%3D+%5Cfrac%7BN%7D%7BN+-+i%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}[M_i] = &#92;frac{N}{N - i}' title='&#92;mathbb{E}[M_i] = &#92;frac{N}{N - i}' class='latex' />. Finally, <img src='http://s0.wp.com/latex.php?latex=T_1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T_1' title='T_1' class='latex' /> is defined as before, and it is clear that <img src='http://s0.wp.com/latex.php?latex=T_1+%3D+1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T_1 = 1' title='T_1 = 1' class='latex' /> day since whoever enters on the first day is automatically a first-time visitor to the room. By linearity of expectation, the expected time for the prisoners&#8217; release is given as follows:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D%5BU%5D+%3D+N+%5Ccdot+%5Csum_%7Bi%3D1%7D%5EN+%5Cfrac%7B1%7D%7Bi%7D+%2B+N+%5Ccdot+%28N-1%29%7E.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}[U] = N &#92;cdot &#92;sum_{i=1}^N &#92;frac{1}{i} + N &#92;cdot (N-1)~.' title='&#92;mathbb{E}[U] = N &#92;cdot &#92;sum_{i=1}^N &#92;frac{1}{i} + N &#92;cdot (N-1)~.' class='latex' /></p>
<p>For <img src='http://s0.wp.com/latex.php?latex=N+%3D+100&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = 100' title='N = 100' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BE%7D%5BU%5D+%5Capprox+10%2C419&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbb{E}[U] &#92;approx 10,419' title='&#92;mathbb{E}[U] &#92;approx 10,419' class='latex' /> days, which is over 28 years! By that time, the warden will likely have retired and been replaced by a new warden who doesn&#8217;t respect the deal.</p>
<p>I have a bit more to say about the problem, but for now, I&#8217;ll leave you with a couple problems to consider.</p>
<ol>
<li>Show that for <img src='http://s0.wp.com/latex.php?latex=N+%3E+3&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N &gt; 3' title='N &gt; 3' class='latex' />, there exists no strategy for which the expected time to release is equal to the expected time to collect <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> coupons.</li>
<li>Find a nontrivial lower bound in terms of <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> for the minimum expected time to release.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/puzzledover.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/puzzledover.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=puzzledover.wordpress.com&#038;blog=14324163&#038;post=17&#038;subd=puzzledover&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://puzzledover.wordpress.com/2010/06/25/100-prisoners/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04ddb5b27693f7ef2a25b2d02603ae54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">K</media:title>
		</media:content>
	</item>
	</channel>
</rss>
