<?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: Shut up and program!</title>
	<atom:link href="http://bit-player.org/2008/shut-up-and-program/feed" rel="self" type="application/rss+xml" />
	<link>http://bit-player.org/2008/shut-up-and-program</link>
	<description>An amateur's outlook on computation and mathematics.</description>
	<pubDate>Mon, 15 Mar 2010 18:44:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Mark Myatt</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1781</link>
		<dc:creator>Mark Myatt</dc:creator>
		<pubDate>Thu, 11 Sep 2008 18:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1781</guid>
		<description>Arrogantly suggesting a way to extend this thread ... The "Monty Hall" problem seems to have been suggested as a yardstick. It might be interesting to see how the favoured environments / languages handle this problem.

I have coded the problem in R using 'procedural' code and 'vectorised' code with a million replicates. My 'procedural' version is:

&lt;pre&gt;  win.by.switch &#60;- 0
  win.by.stick &#60;- 0
  for(replicate in 1:1e6)
    {
    prize &#60;- floor(runif(1) * 3 + 1)
    pick &#60;- floor(runif(1) * 3 + 1)
    if(pick == prize) {
      win.by.stick &#60;- win.by.stick + 1 
      } else {
      win.by.switch &#60;- win.by.switch + 1
      }
    }
win.by.stick
win.by.switch&lt;/pre&gt;

This gives:
&lt;pre&gt;
  &#62; win.by.stick
  [1] 333675
  &#62; win.by.switch
  [1] 666325
&lt;/pre&gt;
After running for about 18.6 seconds.

My 'vectorised' version is:

&lt;pre&gt;  prize &#60;- floor(runif(1e6) * 3 + 1)
  pick &#60;- floor(runif(1e6) * 3 + 1)
  table(ifelse(pick == prize, "STICK", "SWITCH"))
&lt;/pre&gt;
This gives:

&lt;pre&gt;   STICK SWITCH 
  333339 666661 
&lt;/pre&gt;
After running for 1.9 seconds.

The 'vectorised' version could be condensed to a one-liner:

 &lt;pre&gt; table(ifelse(floor(runif(1e6) * 3 + 1) == floor(runif(1e6) * 3 + 1), "STICK", "SWITCH"))
&lt;/pre&gt;
This gives:

 &lt;pre&gt;  STICK SWITCH 
  332902 667098 &lt;/pre&gt;

After running for about 1.6 seconds but the code is far from self-documenting.

I apologise in advance if this is a stupid suggestion. Feel free to gloat if I have misunderstood the "Monty Hall" problem .... that would put me in some esteemed company.</description>
		<content:encoded><![CDATA[<p>Arrogantly suggesting a way to extend this thread &#8230; The &#8220;Monty Hall&#8221; problem seems to have been suggested as a yardstick. It might be interesting to see how the favoured environments / languages handle this problem.</p>
<p>I have coded the problem in R using &#8216;procedural&#8217; code and &#8216;vectorised&#8217; code with a million replicates. My &#8216;procedural&#8217; version is:</p>
<pre>  win.by.switch &lt;- 0
  win.by.stick &lt;- 0
  for(replicate in 1:1e6)
    {
    prize &lt;- floor(runif(1) * 3 + 1)
    pick &lt;- floor(runif(1) * 3 + 1)
    if(pick == prize) {
      win.by.stick &lt;- win.by.stick + 1
      } else {
      win.by.switch &lt;- win.by.switch + 1
      }
    }
win.by.stick
win.by.switch</pre>
<p>This gives:</p>
<pre>
  &gt; win.by.stick
  [1] 333675
  &gt; win.by.switch
  [1] 666325
</pre>
<p>After running for about 18.6 seconds.</p>
<p>My &#8216;vectorised&#8217; version is:</p>
<pre>  prize &lt;- floor(runif(1e6) * 3 + 1)
  pick &lt;- floor(runif(1e6) * 3 + 1)
  table(ifelse(pick == prize, "STICK", "SWITCH"))
</pre>
<p>This gives:</p>
<pre>   STICK SWITCH
  333339 666661
</pre>
<p>After running for 1.9 seconds.</p>
<p>The &#8216;vectorised&#8217; version could be condensed to a one-liner:</p>
<pre> table(ifelse(floor(runif(1e6) * 3 + 1) == floor(runif(1e6) * 3 + 1), "STICK", "SWITCH"))
</pre>
<p>This gives:</p>
<pre>  STICK SWITCH
  332902 667098 </pre>
<p>After running for about 1.6 seconds but the code is far from self-documenting.</p>
<p>I apologise in advance if this is a stupid suggestion. Feel free to gloat if I have misunderstood the &#8220;Monty Hall&#8221; problem &#8230;. that would put me in some esteemed company.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david birnbaum</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1778</link>
		<dc:creator>david birnbaum</dc:creator>
		<pubDate>Wed, 10 Sep 2008 18:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1778</guid>
		<description>Excel can certainly be useful.  If the expense is a factor consider OpenOffice.Org which is a free, open-source equivalent to MS Office.  If has a spreadsheet with a substantial fraction of Excel's capabilities and it can read Excel files.</description>
		<content:encoded><![CDATA[<p>Excel can certainly be useful.  If the expense is a factor consider OpenOffice.Org which is a free, open-source equivalent to MS Office.  If has a spreadsheet with a substantial fraction of Excel&#8217;s capabilities and it can read Excel files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John S.</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1777</link>
		<dc:creator>John S.</dc:creator>
		<pubDate>Sun, 07 Sep 2008 17:15:52 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1777</guid>
		<description>And now I see you mentioned Excel. Never mind ....</description>
		<content:encoded><![CDATA[<p>And now I see you mentioned Excel. Never mind &#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John S.</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1776</link>
		<dc:creator>John S.</dc:creator>
		<pubDate>Sun, 07 Sep 2008 17:15:07 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1776</guid>
		<description>I was one of the two who mentioned R, but seeing david birnbaum's reply above. I remembered that when I wanted to demonstrate the correct Monty Hall strategy to my colleagues, I did it on an Excel spreadsheet.

And now I am a bit surprised that no one mentioned Excel. It's certainly not the ideal platform for inquisitive computing, and it costs a lot of money, but in my line of work (engineering) everybody has a copy and knows how to use it. The spreadsheet itself is versatile enough, but if you know how to use the Basic interpreter you can do almost anything. Over the years I've used it quite a lot, to get answers to all kinds of problems.</description>
		<content:encoded><![CDATA[<p>I was one of the two who mentioned R, but seeing david birnbaum&#8217;s reply above. I remembered that when I wanted to demonstrate the correct Monty Hall strategy to my colleagues, I did it on an Excel spreadsheet.</p>
<p>And now I am a bit surprised that no one mentioned Excel. It&#8217;s certainly not the ideal platform for inquisitive computing, and it costs a lot of money, but in my line of work (engineering) everybody has a copy and knows how to use it. The spreadsheet itself is versatile enough, but if you know how to use the Basic interpreter you can do almost anything. Over the years I&#8217;ve used it quite a lot, to get answers to all kinds of problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Petto</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1775</link>
		<dc:creator>Peter Petto</dc:creator>
		<pubDate>Sun, 07 Sep 2008 12:23:18 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1775</guid>
		<description>Although I'm busy at the moment preparing lesson plans for school this week and don't want to get to far off track (I was reading blogs to stimulate my brain, really.)

I wanted to mention a programming language that has been very helpful to me. I'll comment more about it in the future. It's called J and is the latest incarnation of APL -- it's known as a matrix-oriented language (it is) and it's also quite functional.

It's worth a look, at www.jsoftware.com .</description>
		<content:encoded><![CDATA[<p>Although I&#8217;m busy at the moment preparing lesson plans for school this week and don&#8217;t want to get to far off track (I was reading blogs to stimulate my brain, really.)</p>
<p>I wanted to mention a programming language that has been very helpful to me. I&#8217;ll comment more about it in the future. It&#8217;s called J and is the latest incarnation of APL &#8212; it&#8217;s known as a matrix-oriented language (it is) and it&#8217;s also quite functional.</p>
<p>It&#8217;s worth a look, at <a href="http://www.jsoftware.com" rel="nofollow">http://www.jsoftware.com</a> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bearophile</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1774</link>
		<dc:creator>bearophile</dc:creator>
		<pubDate>Sat, 06 Sep 2008 12:33:04 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1774</guid>
		<description>Instead of using C I suggest the D language. The performance profile is similar (often about as fast, sometimes two times slower) it's much nicer to program with, and it helps you avoid lot of bugs. Later, once your program runs, if you see that you need the last bit of extra performance, you can translate it to C usually without too much problems.</description>
		<content:encoded><![CDATA[<p>Instead of using C I suggest the D language. The performance profile is similar (often about as fast, sometimes two times slower) it&#8217;s much nicer to program with, and it helps you avoid lot of bugs. Later, once your program runs, if you see that you need the last bit of extra performance, you can translate it to C usually without too much problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave birnbaum</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1773</link>
		<dc:creator>dave birnbaum</dc:creator>
		<pubDate>Fri, 05 Sep 2008 19:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1773</guid>
		<description>I've used Matlab and Octave is a free, open-source, equivalent that is mostly compatible.  It can even load most Matlab M files.  It's available for Windows, Mac and Linux.

R is also a free alternative.  It's biggest disadvantage is its focus on statistical analysis but otherwise is an excellent program.

There's also SciLab (French website) that is similar.  Also free.

One issue with these programs is their focus on matrix/vector formulation.  This is an advantage in making matrix or vector computation look simple but does require some rethinking of how one organizes one's data.  But worth the effort.

Personally, I use C and (more and more rarely) FORTRAN to do numerical work.  Especially with things like Numerical Recipes available it's easy to assemble a main program and calls to a few subroutines to do many quick problems like simple Monte Carlos.  I did the Monte Hall problem in about 20 minutes when it first came out to "prove" it to our lunch group of physics PhD's. Especially for more computationally intense problems the speed difference between a compiled language and the interpreted ones is significant.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve used Matlab and Octave is a free, open-source, equivalent that is mostly compatible.  It can even load most Matlab M files.  It&#8217;s available for Windows, Mac and Linux.</p>
<p>R is also a free alternative.  It&#8217;s biggest disadvantage is its focus on statistical analysis but otherwise is an excellent program.</p>
<p>There&#8217;s also SciLab (French website) that is similar.  Also free.</p>
<p>One issue with these programs is their focus on matrix/vector formulation.  This is an advantage in making matrix or vector computation look simple but does require some rethinking of how one organizes one&#8217;s data.  But worth the effort.</p>
<p>Personally, I use C and (more and more rarely) FORTRAN to do numerical work.  Especially with things like Numerical Recipes available it&#8217;s easy to assemble a main program and calls to a few subroutines to do many quick problems like simple Monte Carlos.  I did the Monte Hall problem in about 20 minutes when it first came out to &#8220;prove&#8221; it to our lunch group of physics PhD&#8217;s. Especially for more computationally intense problems the speed difference between a compiled language and the interpreted ones is significant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darius Bacon</title>
		<link>http://bit-player.org/2008/shut-up-and-program#comment-1772</link>
		<dc:creator>Darius Bacon</dc:creator>
		<pubDate>Fri, 05 Sep 2008 07:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://bit-player.org/?p=161#comment-1772</guid>
		<description>http://github.com/darius/halp/ is an Emacs frontend for Python I just wrote that I like a lot already for exploratory programming -- people have said it's sort of like a Mathematica notebook (I can't tell, not having Mathematica).

(I didn't post it three weeks ago because it barely existed then. Perhaps it's still too crude to mention.)</description>
		<content:encoded><![CDATA[<p><a href="http://github.com/darius/halp/" rel="nofollow">http://github.com/darius/halp/</a> is an Emacs frontend for Python I just wrote that I like a lot already for exploratory programming &#8212; people have said it&#8217;s sort of like a Mathematica notebook (I can&#8217;t tell, not having Mathematica).</p>
<p>(I didn&#8217;t post it three weeks ago because it barely existed then. Perhaps it&#8217;s still too crude to mention.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
