<?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>binary&#124;fusion</title>
	<atom:link href="http://adamcoster.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://adamcoster.com</link>
	<description>ramblings of a fetal biologist</description>
	<lastBuildDate>Fri, 27 Apr 2012 01:37:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='adamcoster.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/85ad65a99dad159ad6f64a9e7843e0ef?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>binary&#124;fusion</title>
		<link>http://adamcoster.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://adamcoster.com/osd.xml" title="binary&#124;fusion" />
	<atom:link rel='hub' href='http://adamcoster.com/?pushpress=hub'/>
		<item>
		<title>Caffeine Wean</title>
		<link>http://adamcoster.com/2012/04/22/caffeine-wean/</link>
		<comments>http://adamcoster.com/2012/04/22/caffeine-wean/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 19:54:44 +0000</pubDate>
		<dc:creator>adamcoster</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[caffeine]]></category>
		<category><![CDATA[coffee]]></category>
		<category><![CDATA[drug]]></category>
		<category><![CDATA[experiment]]></category>
		<category><![CDATA[headache]]></category>
		<category><![CDATA[wean]]></category>
		<category><![CDATA[withdrawal]]></category>

		<guid isPermaLink="false">http://adamcoster.com/?p=1250</guid>
		<description><![CDATA[I&#8217;ve dosed myself with caffeine every morning since I was 8. If I don&#8217;t have a dose within ~1 hour of waking up, I get a headache that will not leave until the next morning. The caffeine was originally a &#8230; <a href="http://adamcoster.com/2012/04/22/caffeine-wean/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1250&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve dosed myself with caffeine every morning since I was 8. If I don&#8217;t have a dose within ~1 hour of waking up, I get a headache that will not leave until the next morning. The caffeine was originally a medication for migrations that had no clear source. Now it isn&#8217;t clear if I still get those same <a href="http://en.wikipedia.org/wiki/Idiopathic">idiopathic</a> headaches but caffeine treats them, or if I have just swapped whatever that problem was for a caffeine addiction that gives me headaches during withdrawal. I&#8217;ve attempted to kick the habit a few times in the past, but these always ended poorly. So, I decided to try again but with academic rigor so as to decide for good whether my headaches are withdrawal-induced or caffeine-treated.</p>
<p><strong>Hypothesis:</strong> My headaches are caused by <em>withdrawal from caffeine</em>, a substance that I am addicted to.<br />
<strong>Alternative Hypothesis:</strong> My headaches are due to <em>some biological cause</em>, and caffeine treats this undefined problem.</p>
<p><strong>Experimental Approach:</strong> Attempt to slowly wean myself off of caffeine. If I can do this successfully and remain headache-free for an extended period of time, I will take this as evidence for a caffeine addiction. If I cannot, I will take this as evidence for a biological problem.</p>
<p>Today&#8217;s post explains exactly how I plan to do this, in academically painful detail (below the fold).</p>
<p><span id="more-1250"></span></p>
<div class="wp-caption aligncenter" style="width: 468px"><a href="http://www.flickr.com/photos/accoster/7103231619/in/photostream/"><img class="  " title="Start of caffeine weaning." src="http://farm9.staticflickr.com/8157/7103231619_c1c3174482_z.jpg" alt="Figure showing caffeine reduction starting conditions." width="458" height="518" /></a><p class="wp-caption-text"><strong>Figure 1: (A)</strong> My current dose is 2 packets per day. Shown are 24 packets, enough for 12 days. I later added 5 packets to the total.<strong> (B)</strong> Packets claim to weigh 20g, and my scale agrees. Packaging is included in this weight. <strong>(C)</strong> An empty, seal-able, flexible-plastic container weighs 2g. <strong>(D)</strong> The first filled container has a mass of 182g, giving 180g powder. <strong>(E)</strong> The second filled container has a mass of 202g, giving 200g powder. <strong>(F)</strong> The third and final container weighs 200g, for 198g powder.</p></div>
<p>I&#8217;ve been drinking this instant Vietnamese coffee for a long time now, because it gives me a pretty precise daily caffeine dose and has kept me more headache-free than has normal coffee. I attribute this to high variability in brewed coffee, since the amount of grounds used, water temperature, and brew time vary day-to-day and likely have large effects on final caffeine concentration. So the plan is to use this instant coffee, starting on Day 1 with the amount that I am currently using, followed by 1 gram/day reductions. This will be slow process, allowing me to adjust to the reduced caffeine intake. If during this process I hit quantities that fail to prevent headaches, I will stay on that dose until the headaches stop. If I hit a dose that causes daily headaches for at least 5 days, I will conclude that this is a biological problem.</p>
<p>My current dose is 2 packets per day (Fig. 1A), which should be 40g including the packaging. To more precisely determine the daily amount, I emptied 29 packets (14.5 daily doses) into 3 sandwhich bags and weighed each (Fig. 1). The results are summarized in Table 1, and were remarkably close to the expected value (39.9g actual versus 40g expected).</p>
<table style="margin-left:auto;margin-right:auto;width:100%;border-top:1px solid black;border-bottom:1px solid black;">
<caption><i>TABLE 1: Total contents (excluding container weight) of each bag and calculated daily dose (total/14.5 days).</i></caption>
<tbody>
<tr>
<td><strong>BAG1</strong></td>
<td><strong>BAG2</strong></td>
<td><strong>BAG3</strong></td>
<td><strong>TOTAL</strong></td>
<td><strong>DAILY DOSE</strong></td>
</tr>
<tr>
<td>180g</td>
<td>200g</td>
<td>198g</td>
<td>578g</td>
<td>39.9g</td>
</tr>
</tbody>
</table>
<p>&nbsp;<br />Tomorrow marks Day 0 of The Weaning, which I will begin by measuring out 40g into a tared coffee mug using the scale shown in Fig. 1. I will decrease my daily intake linearly, 1g/day, for the days following as described above, and will follow up this post with the results or with problems that I run into.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adamcoster.wordpress.com/1250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adamcoster.wordpress.com/1250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adamcoster.wordpress.com/1250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adamcoster.wordpress.com/1250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adamcoster.wordpress.com/1250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adamcoster.wordpress.com/1250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adamcoster.wordpress.com/1250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adamcoster.wordpress.com/1250/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1250&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adamcoster.com/2012/04/22/caffeine-wean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9997a07906178aea8a4143822c2dbc0?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=PG" medium="image">
			<media:title type="html">sacred atom</media:title>
		</media:content>

		<media:content url="http://farm9.staticflickr.com/8157/7103231619_c1c3174482_z.jpg" medium="image">
			<media:title type="html">Start of caffeine weaning.</media:title>
		</media:content>
	</item>
		<item>
		<title>arduino: reaction time game</title>
		<link>http://adamcoster.com/2012/03/04/arduino-reaction-time-game/</link>
		<comments>http://adamcoster.com/2012/03/04/arduino-reaction-time-game/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 12:19:17 +0000</pubDate>
		<dc:creator>adamcoster</dc:creator>
				<category><![CDATA[computers/software]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[reaction time]]></category>

		<guid isPermaLink="false">http://adamcoster.com/?p=1231</guid>
		<description><![CDATA[As I mentioned in a previous post, I am trying to teach myself some electronics. I&#8217;ve been perusing a pretty good book by Michael McRoberts called &#8220;Beginning Arduino&#8221;, and after putting together one of the first projects I decided to &#8230; <a href="http://adamcoster.com/2012/03/04/arduino-reaction-time-game/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1231&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in <a href="http://adamcoster.com/2012/02/20/adventures-in-electronics/">a previous post</a>, I am trying to teach myself some electronics. I&#8217;ve been perusing a pretty good book by Michael McRoberts called <a href="http://www.amazon.com/Beginning-Arduino-Michael-McRoberts/dp/1430232404/ref=pd_sim_b_3">&#8220;Beginning Arduino&#8221;</a>, and after putting together one of the first projects I decided to have fun with it and write some more interesting code than the one provided. The original scheme gave a series of three LEDs that would turn on as if they were a stop light, and then allow someone to press a button to get the light to change to red so that another LED, representing the pedestrian walk sign, could turn on. This wasn&#8217;t very interesting to me, so I made it into a reaction game instead otherwise using the same circuit. See the video immediately below, and the circuit diagram (made using <a href="http://fritzing.org/">Fritzing</a>) and code below the fold.</p>
<span style="text-align:center; display: block;"><a href="http://adamcoster.com/2012/03/04/arduino-reaction-time-game/"><img src="http://img.youtube.com/vi/AGgPwfQBlfM/2.jpg" alt="" /></a></span>
<p><span id="more-1231"></span></p>
<p><a href="http://adamcoster.files.wordpress.com/2012/03/reaction_time_bb.png"><img class="aligncenter size-full wp-image-1232" title="reaction_time_bb" src="http://adamcoster.files.wordpress.com/2012/03/reaction_time_bb.png?w=500" alt=""   /></a></p>
<p><pre class="brush: cpp; first-line: 1;">
// Public Domain 2012 by A.Coster

// some constants for readability, using booleans to save memory
boolean ON  = 1 ;
boolean OFF = 0 ;

// Arduino pin setup - there are 3 pins used for LEDs,
// 1 for push-button. The pin at index success_led is
// the one the user should try to hit.
byte led_pins[3]       = {8,9,10} ;
byte button_pin        =    2 ;
byte success_led       =    1 ;  // refers to pin 9

// time_change is the number of milliseconds to add upon
// failure or subtract upon success.
// colorswitch_delay is the amount of time that the LED stays
// on. This value has time_change added to/subtracted from it.
// So that the user knows which LED was lit up when they hit
// the button, push_pause defines the number of milliseconds
// that the LED will stay on after the button is pressed.
unsigned int time_change       =   50 ;
unsigned int colorswitch_delay =  500 ;
unsigned int push_pause        = 2000 ;

void setup(){

    for (int i=0 ; i        pinMode( led_pins[i], OUTPUT ) ;
    }
    pinMode( button_pin, INPUT ) ;
}

void loop(){
    // need to keep track of button presses
    // so set the button state to 0 and overwrite
    // later upon button press
    boolean button_state = OFF ;

    // sequentially turn on each LED
    for ( int i=0 ; i        digitalWrite( led_pins[i], HIGH ) ;

        // Check for a button press every 5 milliseconds
        for ( int t=0 ; t            button_state = digitalRead( button_pin ) ;

            // if the button has been pressed, stop
            // switching LEDs so the user knows, and
            // then check if it was the success_led
            if ( button_state == ON ){
                delay( push_pause ) ;

                // set the button state back to off
                button_state = OFF ;
                if ( i == success_led )
                    // if the user hit the right LED,
                    // make it more challenging by
                    // reducing the delay between LED
                    // switches.
                    colorswitch_delay -= time_change ;
                else
                    // if the user was wrong, make it
                    // easier by increasing the delay.
                    colorswitch_delay += time_change ;
                    break ;
                }
            delay( 5 ) ;
        }
        // and turn it off before looping through
        // to turn the next LED on.
        digitalWrite( led_pins[i], LOW ) ;
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adamcoster.wordpress.com/1231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adamcoster.wordpress.com/1231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adamcoster.wordpress.com/1231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adamcoster.wordpress.com/1231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adamcoster.wordpress.com/1231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adamcoster.wordpress.com/1231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adamcoster.wordpress.com/1231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adamcoster.wordpress.com/1231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1231&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adamcoster.com/2012/03/04/arduino-reaction-time-game/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9997a07906178aea8a4143822c2dbc0?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=PG" medium="image">
			<media:title type="html">sacred atom</media:title>
		</media:content>

		<media:content url="http://adamcoster.files.wordpress.com/2012/03/reaction_time_bb.png" medium="image">
			<media:title type="html">reaction_time_bb</media:title>
		</media:content>
	</item>
		<item>
		<title>Breadboard 5V regulator</title>
		<link>http://adamcoster.com/2012/02/22/breadboard-5v-regulator/</link>
		<comments>http://adamcoster.com/2012/02/22/breadboard-5v-regulator/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 12:00:10 +0000</pubDate>
		<dc:creator>adamcoster</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[arduion]]></category>
		<category><![CDATA[breadboard]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[kit]]></category>
		<category><![CDATA[makershed]]></category>
		<category><![CDATA[solarbotics]]></category>

		<guid isPermaLink="false">https://adamcoster.wordpress.com/?p=1219</guid>
		<description><![CDATA[Since I intend to do a lot of fiddling with Arduinos, and because I need the soldering practice, I bought the breadboard voltage regulator kit (by Solarbotics) from Makershed. The kit is simple &#8211; it just requires the soldering of &#8230; <a href="http://adamcoster.com/2012/02/22/breadboard-5v-regulator/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1219&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 219px"><img style="margin-left:5px;margin-right:5px;" title="solarbotics breadboard voltage kit contents" src="http://farm8.staticflickr.com/7063/6915964055_d15c11be77.jpg" alt="solarbotics breadboard voltage kit contents" width="209" height="405" /><p class="wp-caption-text">Fig.1: Kit contents.</p></div>
<p>Since I intend to do a lot of fiddling with <a href="http://arduino.cc/en/">Arduinos</a>, and because I need the soldering practice, I bought the breadboard <a href="http://www.solarbotics.com/products/34020/">voltage regulator kit</a> (by <a href="http://www.solarbotics.com/">Solarbotics</a>) from <a href="http://www.makershed.com/product_p/mksb016.htm">Makershed</a>. The kit is simple &#8211; it just requires the soldering of a handful of parts to the provided board. The instructions are super-clear, so even though I barely know what the parts are and only recently discovered that LEDs have to be connected in a certain direction, the task was easy. I did find, however, that I still totally suck at soldering, even after the purchase of a nicer iron. With time perhaps.</p>
<p>In the end, though it took me probably 5 minutes to solder each joint, I plugged the thing in and it works! This regulator is supposed to hold the voltage at 5V, which is perfect for the Arduino since that is what it outputs. Pretty handy little thing, and if you are a bit more knowledgeable you could make your own from scratch for way cheaper.</p>
<div class="wp-caption aligncenter" style="width: 510px"><img title="solarbotics voltage regulator kit built" src="http://farm8.staticflickr.com/7181/6915969227_55f3e29749.jpg" alt="solarbotics voltage regulator kit built" width="500" height="375" /><p class="wp-caption-text">Fig.2: Assembled kit, plugged in with glowing LED.</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adamcoster.wordpress.com/1219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adamcoster.wordpress.com/1219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adamcoster.wordpress.com/1219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adamcoster.wordpress.com/1219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adamcoster.wordpress.com/1219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adamcoster.wordpress.com/1219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adamcoster.wordpress.com/1219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adamcoster.wordpress.com/1219/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1219&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adamcoster.com/2012/02/22/breadboard-5v-regulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9997a07906178aea8a4143822c2dbc0?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=PG" medium="image">
			<media:title type="html">sacred atom</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7063/6915964055_d15c11be77.jpg" medium="image">
			<media:title type="html">solarbotics breadboard voltage kit contents</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7181/6915969227_55f3e29749.jpg" medium="image">
			<media:title type="html">solarbotics voltage regulator kit built</media:title>
		</media:content>
	</item>
		<item>
		<title>Adventures in Electronics</title>
		<link>http://adamcoster.com/2012/02/20/adventures-in-electronics/</link>
		<comments>http://adamcoster.com/2012/02/20/adventures-in-electronics/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 13:36:10 +0000</pubDate>
		<dc:creator>adamcoster</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[arduino electronics science android asus]]></category>

		<guid isPermaLink="false">https://adamcoster.wordpress.com/?p=1216</guid>
		<description><![CDATA[I&#8217;ve wanted to be able to build small electronic devices for quite some time, but this is one of those areas in which my education is seriously lacking. I&#8217;ve gone through the Makershed Electronics Components Packs and the book that &#8230; <a href="http://adamcoster.com/2012/02/20/adventures-in-electronics/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1216&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve wanted to be able to build small electronic devices for quite some time, but this is one of those areas in which my education is seriously lacking. I&#8217;ve gone through the <a href="http://www.makershed.com">Makershed</a> Electronics Components Packs and the book that goes with them, but really only spent a weekend doing so. And that was a year ago. Now that my graduate school coursework is complete I&#8217;ve decided to do learn this stuff for real, and to mix it up with <a href="http://arduino.cc/">Arduino</a> (an open-hardware microcontroller platform) . I&#8217;ll try to  regularly update this site with the electronics and Arduino projects that I go through. Most of them will be from kits, so this process will also serve to let readers know if the kits are worth while.</p>
<p>I&#8217;m writing this post on my new <a href="http://www.asus.com/Eee/Eee_Pad/Eee_Pad_Transformer_Prime_TF201/">Asus Transformer Prime</a> (with keyboard) and it just feels clumsy as hell. Probably that feeling comes mostly from the Android operating system, which makes text editing a difficult process. And the slowness of switching applications to find links or open other documents also makes this a pain. Perhaps I will get used to it and even begin to like this system over time, but for now I cannot recommend that anyone who wants to do any serious mobile writing (or coding) get one of these things. It seems you&#8217;re much better off with a small laptop.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adamcoster.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adamcoster.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adamcoster.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adamcoster.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adamcoster.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adamcoster.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adamcoster.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adamcoster.wordpress.com/1216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1216&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adamcoster.com/2012/02/20/adventures-in-electronics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9997a07906178aea8a4143822c2dbc0?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=PG" medium="image">
			<media:title type="html">sacred atom</media:title>
		</media:content>
	</item>
		<item>
		<title>Python: shared birthdays</title>
		<link>http://adamcoster.com/2011/07/13/python-shared-birthdays/</link>
		<comments>http://adamcoster.com/2011/07/13/python-shared-birthdays/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 04:31:34 +0000</pubDate>
		<dc:creator>adamcoster</dc:creator>
				<category><![CDATA[computers/software]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[birthday]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://adamcoster.com/?p=1189</guid>
		<description><![CDATA[A few days ago I found myself having a vague recollection of a statistics problem presented at some unknown level in my education. All I could remember was that it had to do with having a room full of people &#8230; <a href="http://adamcoster.com/2011/07/13/python-shared-birthdays/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1189&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few days ago I found myself having a vague recollection of a statistics problem presented at some unknown level in my education. All I could remember was that it had to do with having a room full of people and the probability that any two people in that room would have the same birthday. I remembered the point, which was that it is much more likely than you might think, but I was fuzzy on the details.</p>
<p>After trying to define the problem and find an answer mathematically, I remembered that I suck at statistical reasoning about as much as the average American. So I decided to model the problem with a short Python script and find the answer that way.</p>
<p><strong>The problem:</strong> There are <em><strong>n</strong></em> people (say, at a party) drawn randomly from a population in which the chances of having a birthday on any day is equal to having a birthday on any other (which is not true of real populations (probably)). What is the probability of there being at least two people with the same birthday in the sample?</p>
<p>To put this thing together, I figure we need three things:</p>
<ol>
<li>The ability to generate random numbers (provided by Python&#8217;s<a href="http://docs.python.org/py3k/library/random.html"> random</a> module);</li>
<li>An object representing each person;</li>
<li>A party object full of those people.</li>
</ol>
<p>Then we can add things like the ability to choose how many people we want at the party and how many parties to have, as well as some output for making plots!</p>
<p>First, the Person object. All each person needs is a birthday:</p>
<p><pre class="brush: python; first-line: 1;">
import random
random.seed()

class Person:
    def __init__( self ):
        self.birthday = random.randint( 1, 365 )
</pre></p>
<p><span id="more-1189"></span></p>
<p>After that we need a Party object, which must be able to contain a bunch of people and check to see whether any of them have the same birthday:</p>
<p><pre class="brush: python; first-line: 7;">
class Party:
    def __init__( self, partiers ):
        self.members   = [ Person()        for p      in range(partiers) ]
        self.birthdays = [ member.birthday for member in self.members    ]
        self.check_matching_birthdays()

    def check_matching_birthdays( self ):
        birthday_frequencies = { b:0 for b in self.birthdays }
        for b in self.birthdays: birthday_frequencies[b] += 1
        for b in self.birthdays:
            if birthday_frequencies[b] &lt; 2:
                del birthday_frequencies[b]
        self.matching_dates = len(birthday_frequencies)
</pre></p>
<p>Finally, we need the <em><strong>main()</strong></em> function allowing the user to choose the number of parties and attendees:</p>
<p><pre class="brush: python; first-line: 21;">
def main():
    while True:
        parties  = int(input(&quot;Number of parties:  &quot;))
        partiers = int(input(&quot;Number of partiers: &quot;))
        parties_with_matching_birthdays = 0

        for party in range( parties ):
            party = Party( partiers )
            if party.matching_dates:
                parties_with_matching_birthdays += 1

        print( 'Fraction of parties having at least one match:' )
        print( '   ', parties_with_matching_birthdays / parties )

main()
</pre></p>
<p>Putting it all together we get a simple program that allows you to answer the question given, and for any number of people. As you increase the number of parties, the variability gets smaller and smaller (and, being an inefficient program, the time taken gets longer and longer). The output I get from a few values is:</p>
<div class="wp-caption aligncenter" style="width: 392px"><img title="party birthday simulation" src="https://lh3.googleusercontent.com/-ZFopQDnXaKY/ThvAIAO3fYI/AAAAAAAAANc/caua0HVLxHE/birthdays.png" alt="" width="382" height="242" /><p class="wp-caption-text">Figure 1: Frequency of finding individuals with the same birthday in groups of various sizes.</p></div>
<p>At 25 people there is already a better-than-even chance of finding two people with the same birthday, and by 50 it&#8217;s almost guaranteed! That does seem a little unbelievable, so I&#8217;ll refer you to the <a href="http://en.wikipedia.org/wiki/Birthday_problem">Wikipedia page</a> on the topic for the math (yes, there really is a page for this).</p>
<p>Just to see if this little simulation would recreate what Wikipedia shows, we can modify the <em><strong>main()</strong></em> function and change it to the following:</p>
<p><pre class="brush: python; first-line: 21;">
def main():
    max_partiers      = 60
    number_of_parties = 10000
    iterations        = 3

    with open( 'birthdays.r', 'w' ) as rfile:
        # First add the variable containing each number of people.
        rfile.write( 'people = c( 1' )
        for partier in range( 2, max_partiers+1 ):
            rfile.write( ', ' + str(partier) )
        rfile.write( ')\n' )

        # Then the variables for the matches in each iteration.
        for iteration in range(iterations):
            rfile.write( 'matches' + str( iteration ) + ' = c( 0' )
            for partiers in range( 2, max_partiers+1 ):
                print( 'iteration =', iteration, 'partiers =', partiers )
                matches = 0
                for party in range( number_of_parties ):
                    party = Party( partiers )
                    if party.matching_dates:
                        matches += 1
                rfile.write( ', ' + str( matches / number_of_parties ) )
            rfile.write( ')\n' )

main()
</pre></p>
<p>Plotting the results in R gives:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class="  " style="margin-top:10px;margin-bottom:10px;" title="simulated_birthday" src="https://lh4.googleusercontent.com/-Ywy76A3glPE/Th5wTWd0XSI/AAAAAAAAAds/aKd6gmTfXSU/g527.png" alt="" width="400" height="300" /><p class="wp-caption-text">Figure 2: Output of simulation. Plotted in R using the Cairo package.</p></div>
<p>And overlaying it onto the Wikipedia plot:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class="  " style="margin-top:10px;margin-bottom:10px;" title="overlay" src="https://lh5.googleusercontent.com/-wZTS4CgBrWI/Th5vYRjJnHI/AAAAAAAAAbY/-M0mK_YC2VA/g7391.png" alt="" width="400" height="256" /><p class="wp-caption-text">Figure 3: Overlay (using Inkscape) of simulated values (blue) on Wikipedia&#039;s calculated values (red).</p></div>
<p style="text-align:center;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/adamcoster.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/adamcoster.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/adamcoster.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/adamcoster.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/adamcoster.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/adamcoster.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/adamcoster.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/adamcoster.wordpress.com/1189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=adamcoster.com&amp;blog=2610285&amp;post=1189&amp;subd=adamcoster&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://adamcoster.com/2011/07/13/python-shared-birthdays/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9997a07906178aea8a4143822c2dbc0?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=PG" medium="image">
			<media:title type="html">sacred atom</media:title>
		</media:content>

		<media:content url="https://lh3.googleusercontent.com/-ZFopQDnXaKY/ThvAIAO3fYI/AAAAAAAAANc/caua0HVLxHE/birthdays.png" medium="image">
			<media:title type="html">party birthday simulation</media:title>
		</media:content>

		<media:content url="https://lh4.googleusercontent.com/-Ywy76A3glPE/Th5wTWd0XSI/AAAAAAAAAds/aKd6gmTfXSU/g527.png" medium="image">
			<media:title type="html">simulated_birthday</media:title>
		</media:content>

		<media:content url="https://lh5.googleusercontent.com/-wZTS4CgBrWI/Th5vYRjJnHI/AAAAAAAAAbY/-M0mK_YC2VA/g7391.png" medium="image">
			<media:title type="html">overlay</media:title>
		</media:content>
	</item>
	</channel>
</rss>
