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

<channel>
	<title>johnramey</title>
	<atom:link href="http://johnramey.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnramey.net/blog</link>
	<description>Don&#039;t think. Compute.</description>
	<lastBuildDate>Wed, 07 Dec 2011 23:52:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Wait til the Weekend</title>
		<link>http://johnramey.net/blog/2011/12/07/wait-til-the-weekend-6/</link>
		<comments>http://johnramey.net/blog/2011/12/07/wait-til-the-weekend-6/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 23:52:24 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[Wait til the Weekend]]></category>
		<category><![CDATA[bayesian]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[concentration of measure]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[machine learning]]></category>
		<category><![CDATA[microarray]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[weekend]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=240</guid>
		<description><![CDATA[Python for Statistical Computing MetaOptimize - A Machine Learning Q&#38;A Community (Similar to StackOverflow) Using bootstrap in cluster analysis Git Magic &#8211; A Git Tutorial as a Video Game Analogy Bayesian Reasoning and Machine Learning &#8211; Textbook with free online textbook (in beta) by David Barber. Bioconductor Experiment Data Packages &#8211; A list of packages [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aliquote.org/memos/2011/02/07/python-for-statistical-computing">Python for Statistical Computing</a></p>
<p><a href="http://metaoptimize.com/">MetaOptimize </a>- A Machine Learning Q&amp;A Community (Similar to StackOverflow)</p>
<p><a href="http://aliquote.org/memos/2011/05/22/using-bootstrap-in-cluster-analysis">Using bootstrap in cluster analysis</a></p>
<p><a href="http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html">Git Magic</a> &#8211; A Git Tutorial as a Video Game Analogy</p>
<p><a href="http://web4.cs.ucl.ac.uk/staff/D.Barber/pmwiki/pmwiki.php?n=Main.Textbook">Bayesian Reasoning and Machine Learning</a> &#8211; Textbook with <strong>free </strong>online textbook (in beta) by David Barber.</p>
<p><a href="http://www.bioconductor.org/packages/release/data/experiment/">Bioconductor Experiment Data Packages</a> &#8211; A list of packages with experiment data (a lot of microarray)</p>
<p><a href="http://www.biostat.harvard.edu/~carey/ov11.pdf">Bioconductor One-day Overview Course</a> &#8211; From Harvard Biostatistics Department (PDF)</p>
<p><a href="http://www.hmwu.idv.tw/web/CourseSMDA/MADA/3-Hank_MADA_VizC_20071106.pdf">Clustering and Visualization of Microarray Data</a> &#8211; This is the best presentation I have seen of the topics, including clustering evaluation (PDF)</p>
<p><a href="http://www.hmwu.idv.tw/web/CourseSMDA/MADA/Hank_MicroarrayDataAnalysis-20080424.pdf">Statistical Microarray Data Analysis</a> &#8211; This excellent presentation from the same guy includes the one above and discusses a much broader scope. (PDF)</p>
<p><a href="http://www.hmwu.idv.tw/hmwu/index.php/mada">Han-Ming Wu&#8217;s Site</a> &#8211; This is the professor that released the above two presentations. He has more information on his site. (Only some English)</p>
<p><a href="http://jasonpriem.com/self-archived/5uni-poster.png">Very slick poster with ggplot2 graphics</a> &#8211; Note the <a href="https://github.com/jasonpriem/5uni-Twitter-study">github project</a> at the bottom.</p>
<p><a href="http://inside.mines.edu/~tvincent/Info/Presentations.html">Concentrations of Measure</a> &#8211; This is Prof. Tyrone Vincent&#8217;s great presentation on probability inequalities from PASI</p>
<p><a href="http://www.cs.cmu.edu/~tom/10701_sp11/lectures.shtml">Machine Learning Video Lectures and Notes</a> &#8211; Professor Tom Mitchell at Carnegie Mellon</p>
<p><a href="http://www.scholarpedia.org/article/Bayesian_statistics">Bayesian Statistics</a> &#8211; Scholarpedia Entry (Recommended by <a href="http://andrewgelman.com/2011/09/my-wikipedia-edit/">Prof. Andrew Gelman</a>)</p>
<p><a href="http://web2.uwindsor.ca/math/hlynka/stochOnline.html">A Large Collection of Notes on Stochastic Processes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/12/07/wait-til-the-weekend-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steve Jobs&#8217; 2005 Stanford Commencement Address</title>
		<link>http://johnramey.net/blog/2011/12/04/steve-jobs-2005-stanford-commencement-address/</link>
		<comments>http://johnramey.net/blog/2011/12/04/steve-jobs-2005-stanford-commencement-address/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 19:57:51 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[commencement]]></category>
		<category><![CDATA[motivation]]></category>
		<category><![CDATA[stanford]]></category>
		<category><![CDATA[steve jobs]]></category>
		<category><![CDATA[wisdom]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=261</guid>
		<description><![CDATA[Given that there are almost 13 million views of Steve Jobs&#8217; commencement address, I am certain that I missed this video when it went viral. I am glad that I did not see it until now because I may not have appreciated his words of wisdom. And although there are numerous quotes that I could [...]]]></description>
			<content:encoded><![CDATA[<p>Given that there are almost 13 million views of Steve Jobs&#8217; commencement address, I am certain that I missed this video when it went viral. I am glad that I did not see it until now because I may not have appreciated his words of wisdom. And although there are numerous quotes that I could list, I think my favorites are closely related to a few words of wisdom that my grandmother told me when I was younger.</p>
<blockquote><p>Don&#8217;t settle.</p></blockquote>
<blockquote><p>Stay hungry. Stay foolish.</p></blockquote>
<blockquote><p>You&#8217;ve got to find what you love, and that is as true for work as is for your lovers. Your work is gonna fill a large part of your life, and the only way to truly be satisfied is to do what you believe is great work, and the only way to do great work is to love what you do.</p></blockquote>
<p>It&#8217;s good to be reminded of things like this once in a while.</p>
<p><iframe width="500" height="375" src="http://www.youtube.com/embed/UF8uR6Z6KLc?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/12/04/steve-jobs-2005-stanford-commencement-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pseudo-Random vs. Random Numbers in R</title>
		<link>http://johnramey.net/blog/2011/11/25/pseudo-random-vs-random-numbers-in-r/</link>
		<comments>http://johnramey.net/blog/2011/11/25/pseudo-random-vs-random-numbers-in-r/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 09:08:11 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[pseudo-random numbers]]></category>
		<category><![CDATA[random numbers]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=239</guid>
		<description><![CDATA[Happy Thanksgiving, everyone. Earlier today, I found an interesting post from Bo Allen on pseudo-random vs random numbers, where the author uses a simple bitmap (heat map) to show that the rand function in PHP has a systematic pattern and compares these to truly random numbers obtained from random.org. The post&#8217;s results suggest that pseudo-randomness in PHP is [...]]]></description>
			<content:encoded><![CDATA[<p>Happy Thanksgiving, everyone. Earlier today, I found <a href="http://www.boallen.com/random-numbers.html">an interesting post from Bo Allen</a> on <a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator">pseudo-random</a> vs <a href="http://en.wikipedia.org/wiki/Random_number">random numbers</a>, where the author uses a simple bitmap (<a href="http://en.wikipedia.org/wiki/Heat_map">heat map</a>) to show that the <strong>rand</strong> function in <a href="http://www.php.net/">PHP</a> has a systematic pattern and compares these to <strong>truly</strong> <strong>random</strong> numbers obtained from <a href="http://www.random.org/">random.org</a>. The post&#8217;s results suggest that pseudo-randomness in <a href="http://www.php.net/">PHP</a> is faulty and, in general, should not be underestimated in practice. Of course, the findings should not be too surprising, as there is a large body of literature on the subtleties, philosophies, and implications of the <strong>pseudo</strong> aspect of the most common approaches to random number generation. However, it is silly that <a href="http://www.php.net/">PHP</a>&#8216;s <a href="http://en.wikipedia.org/wiki/Random_number_generation">random number generator (RNG)</a> displays such an obvious pattern nowadays because there are several decent, well-studied pseudo-<a href="http://en.wikipedia.org/wiki/Random_number_generation">RNG</a> algorithms available as well as numerous tests for randomness.  For a good introduction to <a href="http://en.wikipedia.org/wiki/Random_number_generation">RNG</a>, I recommend <a href="http://www.johndcook.com/blog/2010/12/06/how-to-test-a-random-number-generator-2/">John D. Cook&#8217;s discussion on testing a random number generator</a>.</p>
<p>Now, I would never use <a href="http://www.php.net/">PHP</a> for any (serious) statistical analysis, partly due to my fondness for <a href="http://www.r-project.org/">R</a>, nor do I doubt the practicality of the <a href="http://en.wikipedia.org/wiki/Random_number_generation">RNG</a> in <a href="http://www.r-project.org/">R</a>. But I was curious to see what would happen. So, created equivalent plots in <a href="http://www.r-project.org/">R</a> to see if a <strong>rand</strong> equivalent would exhibit a systematic pattern like in <a href="http://www.php.net/">PHP</a>, even if less severe. Also, for comparison, I chose to use <a href="http://cran.r-project.org/web/packages/random/index.html">the <strong>random</strong> package</a>, from <a href="http://dirk.eddelbuettel.com/">Dirk Eddelbuettel</a>, to draw <strong>truly random</strong> numbers from <a href="http://www.random.org/">random.org</a>. Until today, I had only heard of the <strong>random</strong> package but had never used it.</p>
<p>I have provided the function <strong>rand_bit_matrix</strong>, which requires the number of rows and columns to display in the plotted bitmap. To create the bitmaps, I used the <a href="http://cran.r-project.org/web/packages/pixmap/index.html"><strong>pixmap</strong> package</a> rather than the much-loved <a href="http://had.co.nz/ggplot2/"><strong>ggplot2</strong> package</a>, simply because of how easy it was for me to create the plots. (If you are concerned that I have lost the faith, please note that I am aware of the awesomeness of <strong><a href="http://had.co.nz/ggplot2/">ggplot2</a></strong> and <a href="http://johnramey.net/blog/2011/06/05/conways-game-of-life-in-r-with-ggplot2-and-animation/">its ability</a> <a href="http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/">to create heat maps</a>.)</p>
<p>It is important to note that there were two challenges that I encountered when using drawing <strong>truly random numbers</strong>.</p>
<ol>
<li>Only 10,000 numbers can be drawn at once from <a href="http://www.random.org/">random.org</a>. (This is denoted as <strong>max_n_random.org</strong> in the function below.)</li>
<li>There is a daily limit to the number of times the <a href="http://www.random.org/">random.org</a> service will provide numbers.</li>
</ol>
<p>To overcome the first challenge, I split the total number of bits into separate calls, if necessary. This approach, however, increases our number of requests, and after too many requests, you will see the error: <strong>random.org suggests to wait until tomorrow</strong>. Currently, I do not know the exact number of allowed requests or if the amount of requested random numbers is a factor, but looking back, I would guess about 20ish large requests is too much.</p>
<p>Below, I have plotted 500 x 500 bitmaps based on the <em>random</em> bits from both of <a href="http://www.r-project.org/">R</a> and <a href="http://www.random.org/">random.org</a>. As far as I can tell, no apparent patterns are visible in either plot, but from the graphics alone, our conclusions are limited to ruling out obvious systematic patterns, which were exhibited from the <a href="http://www.php.net/">PHP</a> code. I am unsure if the <a href="http://www.php.net/">PHP</a> folks formally tested their <a href="http://en.wikipedia.org/wiki/Random_number_generation">RNG</a> algorithms for <strong>randomness</strong>, but even if they did, the code in both <a href="http://www.r-project.org/">R</a> and <a href="http://www.php.net/">PHP</a> is straightforward and provides a quick eyeball test. Armed with similar plots alone, the <a href="http://www.php.net/">PHP</a> devs could have sought for better <a href="http://en.wikipedia.org/wiki/Random_number_generation">RNG</a> algorithms &#8212; perhaps, borrowed those from <a href="http://www.r-project.org/">R</a>.</p>
<p>Click the images for a larger view.</p>
<p style="text-align: center;"><a href="http://johnramey.net/blog/wp-content/uploads/2011/11/bitmap_R.png"><img class="aligncenter size-large wp-image-272" style="border-style: none; border-color: white; border-width: 0px;" title="Pseudo-Random Bits in R" src="http://johnramey.net/blog/wp-content/uploads/2011/11/bitmap_R-1024x617.png" alt="" width="768" height="463" /></a></p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://johnramey.net/blog/wp-content/uploads/2011/11/bitmap_random_org.png"><img class="aligncenter size-large wp-image-273" style="border-style: none; border-color: #ffffff; border-width: 0px;" title="Truly Random Bits from Random.org" src="http://johnramey.net/blog/wp-content/uploads/2011/11/bitmap_random_org-1024x617.png" alt="" width="768" height="463" /></a></p>
<p>&nbsp;</p>
<p>Finally, I have provided my <a href="http://www.r-project.org/">R</a> code, which you may tinker with, copy, manipulate, utilize, etc. without legal action and without fear of <a href="http://www.hulu.com/watch/4476/futurama-death-by-snoo-snoo">death by snoo snoo</a>. Mmmm. Snoo snoo.</p>
<p>&nbsp;</p>
<div id="gist1392602" class="gist">
      <div class="gist-file">
        <div class="gist-data gist-syntax">



  <div class="file-data">
    <table cellpadding="0" cellspacing="0" class="lines highlight">
      <tr>
        <td class="line-numbers">
          <span class="line-number" id="file-gistfile1-r-L1" rel="file-gistfile1-r-L1">1</span>
          <span class="line-number" id="file-gistfile1-r-L2" rel="file-gistfile1-r-L2">2</span>
          <span class="line-number" id="file-gistfile1-r-L3" rel="file-gistfile1-r-L3">3</span>
          <span class="line-number" id="file-gistfile1-r-L4" rel="file-gistfile1-r-L4">4</span>
          <span class="line-number" id="file-gistfile1-r-L5" rel="file-gistfile1-r-L5">5</span>
          <span class="line-number" id="file-gistfile1-r-L6" rel="file-gistfile1-r-L6">6</span>
          <span class="line-number" id="file-gistfile1-r-L7" rel="file-gistfile1-r-L7">7</span>
          <span class="line-number" id="file-gistfile1-r-L8" rel="file-gistfile1-r-L8">8</span>
          <span class="line-number" id="file-gistfile1-r-L9" rel="file-gistfile1-r-L9">9</span>
          <span class="line-number" id="file-gistfile1-r-L10" rel="file-gistfile1-r-L10">10</span>
          <span class="line-number" id="file-gistfile1-r-L11" rel="file-gistfile1-r-L11">11</span>
          <span class="line-number" id="file-gistfile1-r-L12" rel="file-gistfile1-r-L12">12</span>
          <span class="line-number" id="file-gistfile1-r-L13" rel="file-gistfile1-r-L13">13</span>
          <span class="line-number" id="file-gistfile1-r-L14" rel="file-gistfile1-r-L14">14</span>
          <span class="line-number" id="file-gistfile1-r-L15" rel="file-gistfile1-r-L15">15</span>
          <span class="line-number" id="file-gistfile1-r-L16" rel="file-gistfile1-r-L16">16</span>
          <span class="line-number" id="file-gistfile1-r-L17" rel="file-gistfile1-r-L17">17</span>
          <span class="line-number" id="file-gistfile1-r-L18" rel="file-gistfile1-r-L18">18</span>
          <span class="line-number" id="file-gistfile1-r-L19" rel="file-gistfile1-r-L19">19</span>
          <span class="line-number" id="file-gistfile1-r-L20" rel="file-gistfile1-r-L20">20</span>
          <span class="line-number" id="file-gistfile1-r-L21" rel="file-gistfile1-r-L21">21</span>
          <span class="line-number" id="file-gistfile1-r-L22" rel="file-gistfile1-r-L22">22</span>
          <span class="line-number" id="file-gistfile1-r-L23" rel="file-gistfile1-r-L23">23</span>
          <span class="line-number" id="file-gistfile1-r-L24" rel="file-gistfile1-r-L24">24</span>
          <span class="line-number" id="file-gistfile1-r-L25" rel="file-gistfile1-r-L25">25</span>
          <span class="line-number" id="file-gistfile1-r-L26" rel="file-gistfile1-r-L26">26</span>
          <span class="line-number" id="file-gistfile1-r-L27" rel="file-gistfile1-r-L27">27</span>
          <span class="line-number" id="file-gistfile1-r-L28" rel="file-gistfile1-r-L28">28</span>
          <span class="line-number" id="file-gistfile1-r-L29" rel="file-gistfile1-r-L29">29</span>
          <span class="line-number" id="file-gistfile1-r-L30" rel="file-gistfile1-r-L30">30</span>
          <span class="line-number" id="file-gistfile1-r-L31" rel="file-gistfile1-r-L31">31</span>
          <span class="line-number" id="file-gistfile1-r-L32" rel="file-gistfile1-r-L32">32</span>
          <span class="line-number" id="file-gistfile1-r-L33" rel="file-gistfile1-r-L33">33</span>
          <span class="line-number" id="file-gistfile1-r-L34" rel="file-gistfile1-r-L34">34</span>
          <span class="line-number" id="file-gistfile1-r-L35" rel="file-gistfile1-r-L35">35</span>
          <span class="line-number" id="file-gistfile1-r-L36" rel="file-gistfile1-r-L36">36</span>
          <span class="line-number" id="file-gistfile1-r-L37" rel="file-gistfile1-r-L37">37</span>
          <span class="line-number" id="file-gistfile1-r-L38" rel="file-gistfile1-r-L38">38</span>
          <span class="line-number" id="file-gistfile1-r-L39" rel="file-gistfile1-r-L39">39</span>
          <span class="line-number" id="file-gistfile1-r-L40" rel="file-gistfile1-r-L40">40</span>
          <span class="line-number" id="file-gistfile1-r-L41" rel="file-gistfile1-r-L41">41</span>
          <span class="line-number" id="file-gistfile1-r-L42" rel="file-gistfile1-r-L42">42</span>
          <span class="line-number" id="file-gistfile1-r-L43" rel="file-gistfile1-r-L43">43</span>
          <span class="line-number" id="file-gistfile1-r-L44" rel="file-gistfile1-r-L44">44</span>
          <span class="line-number" id="file-gistfile1-r-L45" rel="file-gistfile1-r-L45">45</span>
          <span class="line-number" id="file-gistfile1-r-L46" rel="file-gistfile1-r-L46">46</span>
          <span class="line-number" id="file-gistfile1-r-L47" rel="file-gistfile1-r-L47">47</span>
        </td>
        <td class="line-data">
          <pre class="line-pre"><div class="line" id="file-gistfile1-r-LC1">library<span class="p">(</span><span class="s">&#39;plyr&#39;</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC2">library<span class="p">(</span><span class="s">&#39;pixmap&#39;</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC3">library<span class="p">(</span><span class="s">&#39;random&#39;</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC4">&nbsp;</div><div class="line" id="file-gistfile1-r-LC5">rand_bit_matrix <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span>num_rows <span class="o">=</span> <span class="m">500</span><span class="p">,</span> num_cols <span class="o">=</span> <span class="m">500</span><span class="p">,</span></div><div class="line" id="file-gistfile1-r-LC6">  max_n_random.org <span class="o">=</span> <span class="m">10000</span><span class="p">,</span> seed <span class="o">=</span> <span class="kc">NULL</span><span class="p">)</span> <span class="p">{</span></div><div class="line" id="file-gistfile1-r-LC7">  <span class="c1"># I have copied the following function directly from help(&quot;integer&quot;).</span></div><div class="line" id="file-gistfile1-r-LC8">  is.wholenumber <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span>x<span class="p">,</span> tol <span class="o">=</span> .Machine<span class="o">$</span>double.eps<span class="o">^</span><span class="m">0.5</span><span class="p">)</span> <span class="p">{</span></div><div class="line" id="file-gistfile1-r-LC9">    abs<span class="p">(</span>x <span class="o">-</span> round<span class="p">(</span>x<span class="p">))</span> <span class="o">&lt;</span> tol</div><div class="line" id="file-gistfile1-r-LC10">  <span class="p">}</span></div><div class="line" id="file-gistfile1-r-LC11">  </div><div class="line" id="file-gistfile1-r-LC12">  <span class="c1"># The number of bits to draw at &quot;random&quot;.</span></div><div class="line" id="file-gistfile1-r-LC13">  n <span class="o">&lt;-</span> num_rows <span class="o">*</span> num_cols</div><div class="line" id="file-gistfile1-r-LC14">  <span class="kr">if</span><span class="p">(</span>n <span class="o">&lt;=</span> <span class="m">0</span> <span class="o">||</span> <span class="o">!</span>is.wholenumber<span class="p">(</span>n<span class="p">))</span> <span class="p">{</span></div><div class="line" id="file-gistfile1-r-LC15">    stop<span class="p">(</span><span class="s">&quot;The number of bits &#39;n&#39; should be a natural number.&quot;</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC16">  <span class="p">}</span></div><div class="line" id="file-gistfile1-r-LC17">&nbsp;</div><div class="line" id="file-gistfile1-r-LC18">  <span class="kr">if</span><span class="p">(</span><span class="o">!</span>is.null<span class="p">(</span>seed<span class="p">))</span> <span class="p">{</span></div><div class="line" id="file-gistfile1-r-LC19">    set.seed<span class="p">(</span>seed<span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC20">  <span class="p">}</span></div><div class="line" id="file-gistfile1-r-LC21">&nbsp;</div><div class="line" id="file-gistfile1-r-LC22">  <span class="c1"># Create a matrix of pseudo-random bits.</span></div><div class="line" id="file-gistfile1-r-LC23">  bits_R <span class="o">&lt;-</span> replicate<span class="p">(</span>n <span class="o">=</span> num_cols<span class="p">,</span> sample<span class="p">(</span>c<span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">1</span><span class="p">),</span> size <span class="o">=</span> num_rows<span class="p">,</span> replace <span class="o">=</span> <span class="kc">TRUE</span><span class="p">))</span></div><div class="line" id="file-gistfile1-r-LC24">  </div><div class="line" id="file-gistfile1-r-LC25">  <span class="c1"># Because random.org will only return a maximum of 10,000 numbers at a time,</span></div><div class="line" id="file-gistfile1-r-LC26">  <span class="c1"># we break this up into several calls.</span></div><div class="line" id="file-gistfile1-r-LC27">  seq_n_random.org <span class="o">&lt;-</span> rep.int<span class="p">(</span>x <span class="o">=</span> max_n_random.org<span class="p">,</span> times <span class="o">=</span> n <span class="o">%/%</span> max_n_random.org<span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC28">  <span class="kr">if</span><span class="p">(</span>n <span class="o">%%</span> max_n_random.org <span class="o">&gt;</span> <span class="m">0</span><span class="p">)</span> <span class="p">{</span></div><div class="line" id="file-gistfile1-r-LC29">    seq_n_random.org <span class="o">&lt;-</span> c<span class="p">(</span>seq_n_random.org<span class="p">,</span> n <span class="o">%%</span> max_n_random.org<span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC30">  <span class="p">}</span></div><div class="line" id="file-gistfile1-r-LC31">  bits_random.org <span class="o">&lt;-</span> lapply<span class="p">(</span>seq_n_random.org<span class="p">,</span> <span class="kr">function</span><span class="p">(</span>n<span class="p">)</span> <span class="p">{</span></div><div class="line" id="file-gistfile1-r-LC32">    try_default<span class="p">(</span>randomNumbers<span class="p">(</span>n <span class="o">=</span> n<span class="p">,</span> min <span class="o">=</span> <span class="m">0</span><span class="p">,</span> max <span class="o">=</span> <span class="m">1</span><span class="p">,</span> col <span class="o">=</span> <span class="m">1</span><span class="p">),</span> <span class="kc">NA</span><span class="p">)</span> </div><div class="line" id="file-gistfile1-r-LC33">  <span class="p">})</span></div><div class="line" id="file-gistfile1-r-LC34">  </div><div class="line" id="file-gistfile1-r-LC35">  bits_random.org <span class="o">&lt;-</span> matrix<span class="p">(</span>unlist<span class="p">(</span>bits_random.org<span class="p">),</span> nrow <span class="o">=</span> num_rows<span class="p">,</span> ncol <span class="o">=</span> num_cols<span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC36">  </div><div class="line" id="file-gistfile1-r-LC37">  list<span class="p">(</span>R <span class="o">=</span> bits_R<span class="p">,</span> random.org <span class="o">=</span> bits_random.org<span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC38"><span class="p">}</span></div><div class="line" id="file-gistfile1-r-LC39">&nbsp;</div><div class="line" id="file-gistfile1-r-LC40">bit_mats <span class="o">&lt;-</span> rand_bit_matrix<span class="p">(</span>num_rows <span class="o">=</span> <span class="m">500</span><span class="p">,</span> num_cols <span class="o">=</span> <span class="m">500</span><span class="p">,</span> seed <span class="o">=</span> <span class="m">42</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC41">&nbsp;</div><div class="line" id="file-gistfile1-r-LC42">with<span class="p">(</span>bit_mats<span class="p">,</span></div><div class="line" id="file-gistfile1-r-LC43">  plot<span class="p">(</span>pixmapGrey<span class="p">(</span>data <span class="o">=</span> R<span class="p">,</span> nrow <span class="o">=</span> nrow<span class="p">(</span>R<span class="p">),</span> ncol <span class="o">=</span> ncol<span class="p">(</span>R<span class="p">)),</span> main <span class="o">=</span> <span class="s">&quot;R&quot;</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC44"><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC45">with<span class="p">(</span>bit_mats<span class="p">,</span></div><div class="line" id="file-gistfile1-r-LC46">  plot<span class="p">(</span>pixmapGrey<span class="p">(</span>data <span class="o">=</span> random.org<span class="p">,</span> nrow <span class="o">=</span> nrow<span class="p">(</span>random.org<span class="p">),</span> ncol <span class="o">=</span> ncol<span class="p">(</span>random.org<span class="p">)),</span> main <span class="o">=</span> <span class="s">&quot;random.org&quot;</span><span class="p">)</span></div><div class="line" id="file-gistfile1-r-LC47"><span class="p">)</span></div></pre>
        </td>
      </tr>
    </table>
  </div>

        </div>

        <div class="gist-meta">
          <a href="https://gist.github.com/ramey/1392602/raw/398cdef7cbdd4cf91225db1e64fc93c22875aa8f/gistfile1.r" style="float:right">view raw</a>
          <a href="https://gist.github.com/ramey/1392602#file-gistfile1-r" style="float:right; margin-right:10px; color:#666;">gistfile1.r</a>
          <a href="https://gist.github.com/ramey/1392602">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
        </div>
      </div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/11/25/pseudo-random-vs-random-numbers-in-r/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wait til the Weekend</title>
		<link>http://johnramey.net/blog/2011/09/16/wait-til-the-weekend-5/</link>
		<comments>http://johnramey.net/blog/2011/09/16/wait-til-the-weekend-5/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 01:08:24 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[Wait til the Weekend]]></category>
		<category><![CDATA[weekend]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=170</guid>
		<description><![CDATA[My Question on Stack Exchange about Lagrange Multipliers with Inequality Constraints One-liners which make me love R: Make your data dance (Hans Rosling style) with googleVis Response Surface Plot Example in R with rgl Excellent Set of &#8216;Data Mining&#8217; Notes from Professor Shalizi at Carnegie Mellon Annotated Computer Vision Bibliography &#8211; A HUGE list of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://math.stackexchange.com/questions/49473/lagrange-multipliers-with-inequality-constraints">My Question on Stack Exchange about Lagrange Multipliers with Inequality Constraints</a></p>
<p><a href="http://jeffreybreen.wordpress.com/2011/07/14/r-one-liners-googlevis/">One-liners which make me love R: Make your data dance (Hans Rosling style) with googleVis</a></p>
<p><a href="http://r.789695.n4.nabble.com/Response-surface-plot-td891445.html">Response Surface Plot Example in R with <strong>rgl</strong></a></p>
<p><a href="http://www.stat.cmu.edu/~cshalizi/350/">Excellent Set of &#8216;Data Mining&#8217; Notes from Professor Shalizi at Carnegie Mellon</a></p>
<p><a href="http://www.visionbib.com/bibliography/contents.html">Annotated Computer Vision Bibliography</a> &#8211; A HUGE list of links from various disciplines related to pattern recognition, machine learning, facial recognition, etc. Highly recommended for exploration.</p>
<p><a href="http://www.bepress.com/cgi/viewcontent.cgi?article=1252&amp;context=sagmb">A paper from Strimmer Lab that discusses James-Stein  shrinkage estimators related to one of my papers</a></p>
<p><a href="http://bigml.wikispaces.com/file/view/Holmes.pdf">Fast SVD for Large-Scale Matrices</a></p>
<p><a href="http://www.isid.ac.in/~statmath/eprints/2007/isid200703.pdf">Spectral Variation, Normal Matrices, and Finsler Geometry</a> - Provides a great discussion on the development of the Hoffman-Wielandt theorem and describes several inequalities related to the Frobenius norm of the difference of two matrices</p>
<p><a href="http://202.116.32.252/UploadFiles/200877145635317.pdf">A Note on the Hoffman-Wielandt Theorem for Generalized Eigenvalue Problem</a> - An interesting development of diagonalizable pairs of Hermitian matrices.</p>
<p><a href="http://www.research.rutgers.edu/~cmansley/fall08/cs500.html">Seminar Materials for Bayesian Reinforcement Learning</a></p>
<p><a href="http://www.theatlantic.com/magazine/archive/2011/10/the-shame-of-college-sports/8643/"> The Shame of College Sports</a> &#8211; An article that has been highly recommended to me about corruption in college sports</p>
<p><a href="http://ucsdproteomics.blogspot.com/">UCSDs Computational Mass Spec Blog</a> &#8211; I like how they compile papers and comment on them in blog form with various details about each. I am tempted to adopt their method.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/09/16/wait-til-the-weekend-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wait til the Weekend</title>
		<link>http://johnramey.net/blog/2011/06/25/wait-til-the-weekend-4/</link>
		<comments>http://johnramey.net/blog/2011/06/25/wait-til-the-weekend-4/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 21:06:53 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[Wait til the Weekend]]></category>
		<category><![CDATA[weekend]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=153</guid>
		<description><![CDATA[Extending and Embedding R with C++ &#8211; Presentation Mommy, I found it! — 15 Practical Linux Find Command Examples Introduction to Machine Learning &#8211; book by Alex Smola (Yahoo) Applied Multivariate Statistical Analysis &#8211; Excellent book by Hardle and Simar (PDF!) Primer on Matrix Analysis and Linear Models &#8211; Excellent resource for more rigorous approach [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.scribd.com/doc/49944125/DirkEddelbuettel-Tutorial">Extending and Embedding R with C++</a> &#8211; Presentation</p>
<p><a href="http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/">Mommy, I found it! — 15 Practical Linux Find Command Examples</a></p>
<p><a href="http://alex.smola.org/drafts/thebook.pdf">Introduction to Machine Learning</a> &#8211; book by Alex Smola (Yahoo)</p>
<p><a href="http://www.stat.wvu.edu/~jharner/courses/stat541/mva.pdf">Applied Multivariate Statistical Analysis</a> &#8211; Excellent book by Hardle and Simar (PDF!)</p>
<p><a href="http://www.math.montana.edu/~rjboik/classes/550/">Primer on Matrix Analysis and Linear Models</a> &#8211; Excellent resource for more rigorous approach to matrices!!!</p>
<p><a href="http://sc09.sc-education.org/materials/Tuesday.130pm.Biology/Krijnen-IntroBioInfStatistics-1.pdf">Applied Statistics for Bioinformatics using R</a> &#8211; Book (PDF)</p>
<p><a href="http://www.cs.colostate.edu/~anderson/cs545/Lectures/week14day2/week14day2.pdf">Distributed Computing with R Using Snowfall</a> &#8211; Presentation (PDF)</p>
<p><a href="http://www.quora.com/Machine-Learning/How-can-you-learn-Mathematics-for-machine-learning">How can you learn mathematics for machine learning? </a>- Quora</p>
<p><a href="http://www.quora.com/Machine-Learning/What-are-some-good-resources-for-learning-about-machine-learning">What are some good resources for machine learning?</a> &#8211; Quora</p>
<p><a href="http://www.faqs.org/faqs/ai-faq/neural-nets/part1/">Introduction to Neural Networks</a> &#8211; comp.ai.neural-nets newsgroup</p>
<p><a href="http://www.autonlab.org/tutorials/">Statistical Data Mining Tutorials</a> &#8211; Slides by Prof. Andrew Moore at CMU</p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/06/25/wait-til-the-weekend-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listing of Statistics and Machine Learning Conferences</title>
		<link>http://johnramey.net/blog/2011/06/12/listing-of-statistics-and-machine-learning-conferences/</link>
		<comments>http://johnramey.net/blog/2011/06/12/listing-of-statistics-and-machine-learning-conferences/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 23:20:27 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[machine learning]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[conferences]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=149</guid>
		<description><![CDATA[Occasionally, I will query Google with &#8220;statistics conferences&#8221;, &#8220;machine learning conferences&#8221; or &#8220;pattern recognition conferences&#8221; and the like. But often, it is difficult to obtain anything meaningful other than the conferences of which I&#8217;m already aware (such as JSM, ICML, some IEEE conferences). Today, I found WikiCFP, which is a &#8220;A Wiki for Calls For [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally, I will query Google with &#8220;statistics conferences&#8221;, &#8220;machine learning conferences&#8221; or &#8220;pattern recognition conferences&#8221; and the like. But often, it is difficult to obtain anything meaningful other than the conferences of which I&#8217;m already aware (such as JSM, ICML, some IEEE conferences). Today, I found <a href="http://www.wikicfp.com/cfp/">WikiCFP</a>, which is a &#8220;A Wiki for Calls For Papers.&#8221; This seems to be what I needed. In particular, the following are very useful to me:</p>
<ul>
<li><a href="http://www.wikicfp.com/cfp/call?conference=machine%20learning">Machine Learning on WikiCFP</a></li>
<li><a href="http://www.wikicfp.com/cfp/call?conference=statistics">Statistics on WikiCFP</a></li>
</ul>
<p>It seems limited for statistics though, as JSM is not even listed.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/06/12/listing-of-statistics-and-machine-learning-conferences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conway&#8217;s Game of Life in R with ggplot2 and animation</title>
		<link>http://johnramey.net/blog/2011/06/05/conways-game-of-life-in-r-with-ggplot2-and-animation/</link>
		<comments>http://johnramey.net/blog/2011/06/05/conways-game-of-life-in-r-with-ggplot2-and-animation/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 00:04:08 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[game of life]]></category>
		<category><![CDATA[ggplot2]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=133</guid>
		<description><![CDATA[In undergrad I had a computer science professor that piqued my interest in applied mathematics, beginning with Conway&#8217;s Game of Life. At first, the Game of Life (not the board game) appears to be quite simple &#8212; perhaps, too simple &#8212; but it has been widely explored and is useful for modeling systems over time. [...]]]></description>
			<content:encoded><![CDATA[<p>In undergrad I had a computer science professor that piqued my interest in applied mathematics, beginning with <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Conway&#8217;s Game of Life</a>. At first, the Game of Life (not the board game) appears to be quite simple &#8212; perhaps, too simple &#8212; but it has been widely explored and is useful for modeling systems over time. It has been forever since I wrote my first version of this in C++, and I happily report that there will be no nonsense here.</p>
<p>The basic idea is to start with a grid of cells, where each cell is either a zero (dead) or a one (alive). We are interested in watching the population behavior over time to see if the population dies off, has some sort of equilibrium, etc. John Conway studied many possible ways to examine population behaviors and ultimately decided on the following rules, which we apply to each cell for the current tick (or generation).</p>
<ol>
<li>Any live cell with fewer than two live neighbours dies, as if caused by under-population.</li>
<li>Any live cell with two or three live neighbours lives on to the next generation.</li>
<li>Any live cell with more than three live neighbours dies, as if by overcrowding.</li>
<li>Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction</li>
</ol>
<p>Although there are <a href="http://www.statisticsblog.com/2010/05/game-of-life-in-r/">other versions</a> of this in R, I decided to give it a shot myself. I am not going to provide a walkthrough of the code as I may normally do, but the code should be simple enough to understand for one proficient in R. It may have been unnecessary to implement this with the foreach package, but I wanted to get some more familiarity with foreach, so I did.</p>
<p>The set of grids is stored as a list, where each element is a matrix of zeros and ones. Each matrix is then converted to an image with ggplot2, and the sequence of images is exported as a GIF with the animation package.</p>
<p>Let me know if you improve on my code any. I&#8217;m always interested in learning how to do things better.</p>

<div class="wp_codebox"><table><tr id="p1333"><td class="code" id="p133code3"><pre class="c" style="font-family:monospace;">library<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'foreach'</span><span style="color: #009900;">&#41;</span>
library<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'ggplot2'</span><span style="color: #009900;">&#41;</span>
library<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'animation'</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #339933;"># Determines how many neighboring cells around the (j,k)th cell have living organisms.</span>
<span style="color: #339933;"># The conditionals are used to check if we are at a boundary of the grid.</span>
how_many_neighbors <span style="color: #339933;">&lt;-</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">,</span> j<span style="color: #339933;">,</span> k<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size <span style="color: #339933;">&lt;-</span> nrow<span style="color: #009900;">&#40;</span>grid<span style="color: #009900;">&#41;</span>
  count <span style="color: #339933;">&lt;-</span> <span style="color: #0000dd;">0</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> k<span style="color: #009900;">&#93;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>k <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> k<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>k <span style="color: #339933;">&lt;</span> size<span style="color: #009900;">&#41;</span> count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> k<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&lt;</span> size<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>k<span style="color: #009900;">&#93;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>k <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> k<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>k <span style="color: #339933;">&lt;</span> size<span style="color: #009900;">&#41;</span> count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> k<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>k <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">,</span> k<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>k <span style="color: #339933;">&lt;</span> size<span style="color: #009900;">&#41;</span> count <span style="color: #339933;">&lt;-</span> count <span style="color: #339933;">+</span> grid<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">,</span> k<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>
  count
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;"># Creates a list of matrices, each of which is an iteration of the Game of Life.</span>
<span style="color: #339933;"># Arguments</span>
<span style="color: #339933;"># size: the edge length of the square</span>
<span style="color: #339933;"># prob: a vector (of length 2) that gives probability of death and life respectively for initial config</span>
<span style="color: #339933;"># returns a list of grids (matrices)</span>
game_of_life <span style="color: #339933;">&lt;-</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>size <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">,</span> num_reps <span style="color: #339933;">=</span> <span style="color: #0000dd;">50</span><span style="color: #339933;">,</span> prob <span style="color: #339933;">=</span> c<span style="color: #009900;">&#40;</span><span style="color:#800080;">0.5</span><span style="color: #339933;">,</span> <span style="color:#800080;">0.5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  grid <span style="color: #339933;">&lt;-</span> list<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;-</span> replicate<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">,</span> sample<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> size<span style="color: #339933;">,</span> replace <span style="color: #339933;">=</span> TRUE<span style="color: #339933;">,</span> prob <span style="color: #339933;">=</span> prob<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  dev_null <span style="color: #339933;">&lt;-</span> foreach<span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> seq_len<span style="color: #009900;">&#40;</span>num_reps<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span>do<span style="color: #339933;">%</span> <span style="color: #009900;">&#123;</span>
    grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;-</span> grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>
    foreach<span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> seq_len<span style="color: #009900;">&#40;</span>size<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%:%</span>
      foreach<span style="color: #009900;">&#40;</span>k <span style="color: #339933;">=</span> seq_len<span style="color: #009900;">&#40;</span>size<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span>do<span style="color: #339933;">%</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #339933;"># Apply game rules.</span>
        num_neighbors <span style="color: #339933;">&lt;-</span> how_many_neighbors<span style="color: #009900;">&#40;</span>grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> j<span style="color: #339933;">,</span> k<span style="color: #009900;">&#41;</span>
        alive <span style="color: #339933;">&lt;-</span> grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">,</span>k<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>alive <span style="color: #339933;">&amp;&amp;</span> num_neighbors <span style="color: #339933;">&lt;=</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">,</span>k<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;-</span> <span style="color: #0000dd;">0</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>alive <span style="color: #339933;">&amp;&amp;</span> num_neighbors <span style="color: #339933;">&gt;=</span> <span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span> grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">,</span>k<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;-</span> <span style="color: #0000dd;">0</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>alive <span style="color: #339933;">&amp;&amp;</span> num_neighbors <span style="color: #339933;">==</span> <span style="color: #0000dd;">3</span><span style="color: #009900;">&#41;</span> grid<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">,</span>k<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;-</span> <span style="color: #0000dd;">1</span>
      <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  grid
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;"># Converts the current grid (matrix) to a ggplot2 image</span>
grid_to_ggplot <span style="color: #339933;">&lt;-</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>grid<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #339933;"># Permutes the matrix so that melt labels this correctly.</span>
  grid <span style="color: #339933;">&lt;-</span> grid<span style="color: #009900;">&#91;</span>seq.<span style="color: #993333;">int</span><span style="color: #009900;">&#40;</span>nrow<span style="color: #009900;">&#40;</span>grid<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#93;</span>
  grid <span style="color: #339933;">&lt;-</span> melt<span style="color: #009900;">&#40;</span>grid<span style="color: #009900;">&#41;</span>
  grid$value <span style="color: #339933;">&lt;-</span> factor<span style="color: #009900;">&#40;</span>ifelse<span style="color: #009900;">&#40;</span>grid$value<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Alive&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Dead&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  p <span style="color: #339933;">&lt;-</span> ggplot<span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">,</span> aes<span style="color: #009900;">&#40;</span>x<span style="color: #339933;">=</span>X1<span style="color: #339933;">,</span> y<span style="color: #339933;">=</span>X2<span style="color: #339933;">,</span> z <span style="color: #339933;">=</span> value<span style="color: #339933;">,</span> color <span style="color: #339933;">=</span> value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  p <span style="color: #339933;">&lt;-</span> p <span style="color: #339933;">+</span> geom_tile<span style="color: #009900;">&#40;</span>aes<span style="color: #009900;">&#40;</span>fill <span style="color: #339933;">=</span> value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  p  <span style="color: #339933;">+</span> scale_fill_manual<span style="color: #009900;">&#40;</span>values <span style="color: #339933;">=</span> c<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Dead&quot;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Alive&quot;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;black&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As an example, I have created a 20-by-20 grid with a 10% chance that its initial values will be alive. The simulation has 250 iterations. You may add more, but this takes long enough already.</p>

<div class="wp_codebox"><table><tr id="p1334"><td class="code" id="p133code4"><pre class="c" style="font-family:monospace;">game_grids <span style="color: #339933;">&lt;-</span> game_of_life<span style="color: #009900;">&#40;</span>size <span style="color: #339933;">=</span> <span style="color: #0000dd;">20</span><span style="color: #339933;">,</span> num_reps <span style="color: #339933;">=</span> <span style="color: #0000dd;">250</span><span style="color: #339933;">,</span> prob <span style="color: #339933;">=</span> c<span style="color: #009900;">&#40;</span><span style="color:#800080;">0.1</span><span style="color: #339933;">,</span> <span style="color:#800080;">0.9</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
grid_ggplot <span style="color: #339933;">&lt;-</span> lapply<span style="color: #009900;">&#40;</span>game_grids<span style="color: #339933;">,</span> grid_to_ggplot<span style="color: #009900;">&#41;</span>
saveGIF<span style="color: #009900;">&#40;</span>lapply<span style="color: #009900;">&#40;</span>grid_ggplot<span style="color: #339933;">,</span> print<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> clean <span style="color: #339933;">=</span> TRUE<span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p><a href="http://johnramey.net/blog/wp-content/uploads/2011/06/animation.gif"><img class="aligncenter size-full wp-image-139" title="animation" src="http://johnramey.net/blog/wp-content/uploads/2011/06/animation.gif" alt="" width="480" height="480" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/06/05/conways-game-of-life-in-r-with-ggplot2-and-animation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Wait til the Weekend</title>
		<link>http://johnramey.net/blog/2011/06/03/wait-til-the-weekend-3/</link>
		<comments>http://johnramey.net/blog/2011/06/03/wait-til-the-weekend-3/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 18:01:56 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[Wait til the Weekend]]></category>
		<category><![CDATA[weekend]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=118</guid>
		<description><![CDATA[Accuracy of pseudo-inverse covariance learning &#8211; a Random Matrix Theory Analysis (peaking effect!) Machine Learning Data Set Repository Material for Jieping Ye&#8217;s Machine Learning Course &#8211; Lots of papers, links, data sets, and tutorials. Data sets from &#8220;Elements of Statistical Learning&#8221; Benchmark Data Sets for Supervised Classification Rosetta Code (Translation of Various Coding Tasks into [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://personalpages.manchester.ac.uk/staff/david.hoyle/HomePage/PublicationsListByTopic.htm">Accuracy of pseudo-inverse covariance learning &#8211; a Random Matrix Theory Analysis</a> (peaking effect!)</p>
<p><a href="http://mldata.org/">Machine Learning Data Set Repository</a></p>
<p><a href="http://www.public.asu.edu/~jye02/COURSES/">Material for Jieping Ye&#8217;s Machine Learning Course</a> &#8211; Lots of papers, links, data sets, and tutorials.</p>
<p><a href="http://www-stat.stanford.edu/~tibs/ElemStatLearn/data.html">Data sets from &#8220;Elements of Statistical Learning&#8221;</a></p>
<p><a href="http://www.is.umk.pl/projects/datasets.html">Benchmark Data Sets for Supervised Classification</a></p>
<p><a href="http://rosettacode.org/">Rosetta Code</a> (Translation of Various Coding Tasks into Many Programming Languages)</p>
<p><a href="http://rstats.wordpress.com/2011/03/15/visualizing-store-growth/">Visualizing Growth of a Retail Chain in R</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/06/03/wait-til-the-weekend-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wait til the Weekend</title>
		<link>http://johnramey.net/blog/2011/05/25/wait-til-the-weekend-2/</link>
		<comments>http://johnramey.net/blog/2011/05/25/wait-til-the-weekend-2/#comments</comments>
		<pubDate>Wed, 25 May 2011 20:50:08 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[Wait til the Weekend]]></category>
		<category><![CDATA[weekend]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=113</guid>
		<description><![CDATA[StackOverflow &#8211; How to efficiently use Rprof in R? A Random Matrix-Theoretic Approach to Handling Singular Covariance Estimates Shrinkage Discriminant Analysis and Feature Selection (along with sda package on CRAN) Bayesian Model Averaging: A Tutorial (PDF) Statistical Learning Based on High Dimensional Data (PDF: Master&#8217;s Thesis focused on Regularized Discriminant Analysis) Objective Bayesian Analysis of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://stackoverflow.com/questions/3650862/how-to-efficiently-use-rprof-in-r">StackOverflow &#8211; How to efficiently use Rprof in R?</a></p>
<p><a href="http://arxiv.org/abs/arXiv:1010.0601">A Random Matrix-Theoretic Approach to Handling Singular Covariance Estimates</a></p>
<p><a href="http://strimmerlab.org/software/sda/">Shrinkage Discriminant Analysis and Feature Selection</a> (along with <a href="http://cran.r-project.org/web/packages/sda/index.html">sda</a> package on CRAN)</p>
<p><a href="http://www.iipl.fudan.edu.cn/~zhangjp/literatures/cluster%20analysis/hoeting.pdf">Bayesian Model Averaging: A Tutorial</a> (PDF)</p>
<p><a href="http://people.orie.cornell.edu/sc499/PDF%20Files/Stat%20learning.pdf">Statistical Learning Based on High Dimensional Data</a> (PDF: Master&#8217;s Thesis focused on Regularized Discriminant Analysis)</p>
<p><a href="http://scholar.lib.vt.edu/theses/available/etd-06252008-155353/unrestricted/ZhonggaiLI_ETD.pdf">Objective Bayesian Analysis of Kullback-Liebler Divergence of Two Multivariate Normal Distributions with Common CovarianceMatrix and Star-shape Gaussian Graphical Model</a> (PDF: Dissertation)</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/05/25/wait-til-the-weekend-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with Some Baseball Data</title>
		<link>http://johnramey.net/blog/2011/05/24/getting-started-with-some-baseball-data/</link>
		<comments>http://johnramey.net/blog/2011/05/24/getting-started-with-some-baseball-data/#comments</comments>
		<pubDate>Wed, 25 May 2011 03:34:53 +0000</pubDate>
		<dc:creator>ramhiser</dc:creator>
				<category><![CDATA[statistics]]></category>
		<category><![CDATA[baseball]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://johnramey.net/blog/?p=89</guid>
		<description><![CDATA[With all of the discussions (hype?) regarding applied statistics, machine learning, and data science, I have been looking for a go-to source of work-unrelated data. I loved baseball as a kid. I love baseball now. I love baseball stats. Why not do a grown-up version of what I used to do when I spent hours [...]]]></description>
			<content:encoded><![CDATA[<p>With all of the discussions (hype?) regarding applied statistics, machine learning, and data science, I have been looking for a go-to source of work-unrelated data. I loved baseball as a kid. I love baseball now. I love baseball stats. Why not do a grown-up version of what I used to do when I spent hours staring at and memorizing baseball stats on the back of a few pieces of cardboard on which I spent my allowance?</p>
<p>To get started, I purchased a copy of <a href="http://www.amazon.com/Baseball-Hacks-Joseph-Adler/dp/0596009429/ref=sr_1_1?ie=UTF8&amp;qid=1306290220&amp;sr=8-1">Baseball Hacks</a>. The author suggests the usage of MySQL, so I will oblige. First, I downloaded some baseball data in MySQL format on my web server (Ubuntu 10.04) and decompressed it; when I downloaded the data, it was timestamped as 28 March 2011, so double-check if there is an updated version.</p>

<div class="wp_codebox"><table><tr id="p898"><td class="code" id="p89code8"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> baseball
<span style="color: #7a0874; font-weight: bold;">cd</span> baseball
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.baseball-databank.org<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>BDB-sql-<span style="color: #000000;">2011</span>-03-<span style="color: #000000;">28</span>.sql.zip
<span style="color: #c20cb9; font-weight: bold;">unzip</span> BDB-sql-<span style="color: #000000;">2011</span>-03-<span style="color: #000000;">28</span>.sql.zip</pre></td></tr></table></div>

<p>Next, in MySQL I created a user named &#8220;baseball&#8221;, a database entitled &#8220;bbdatabank&#8221; and granted all privileges on this database to the user &#8220;baseball.&#8221; To do this, first open MySQL as root (mysql -u root -p)</p>

<div class="wp_codebox"><table><tr id="p899"><td class="code" id="p89code9"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> USER <span style="color: #ff0000;">'baseball'</span>@<span style="color: #ff0000;">'localhost'</span> <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">'YourPassword'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> databas bbdatabank;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> PRIVILEGES <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #ff0000;">`bbdatabank`</span><span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'baseball'</span>@<span style="color: #ff0000;">'localhost'</span>;
<span style="color: #993333; font-weight: bold;">FLUSH</span> PRIVILEGES;
quit</pre></td></tr></table></div>

<p>Note the tick marks (`) around bbdatabank when privileges are granted. Also, notice the deliberate misspelling when I constructed the db. WordPress freaks out on me because mod_security steps in and says, &#8220;Umm, no.&#8221; For more info about this, go <a href="http://abing.gotdns.com/posts/2006/wordpress-error-404-when-publishing-or-saving-post/">here</a> and <a href="http://drupal.org/node/110204">here</a> (see the comments as well).</p>
<p>Finally, we read the data into the database we just created by:</p>

<div class="wp_codebox"><table><tr id="p8910"><td class="code" id="p89code10"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> baseball <span style="color: #660033;">-p</span> <span style="color: #660033;">-s</span> bbdatabank <span style="color: #000000; font-weight: bold;">&lt;</span> BDB-sql-<span style="color: #000000;">2011</span>-03-<span style="color: #000000;">28</span>.sql</pre></td></tr></table></div>

<p>That&#8217;s it! Most of this code has been adapted from the <a href="http://www.amazon.com/Baseball-Hacks-Joseph-Adler/dp/0596009429/ref=sr_1_1?ie=UTF8&amp;qid=1306290220&amp;sr=8-1">Baseball Hacks</a> book, although I&#8217;ve tweaked a couple of things. As I progress through the book, I will continue to add interesting finds and code as posts. Eventually, I will move away from the book&#8217;s code as it focuses too much on the &#8220;Intro to Data Exploration&#8221; reader with constant mentions of MS Access/Excel. The author means well though as he urges the reader to use *nix/Mac OS X.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnramey.net/blog/2011/05/24/getting-started-with-some-baseball-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
