<?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>Malte&#039;s Blog</title>
	<atom:link href="http://www.malteahrens.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.malteahrens.com/blog</link>
	<description>Malte&#039;s Blog</description>
	<lastBuildDate>Mon, 11 Feb 2013 09:18:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>The beginnings of a scibot</title>
		<link>http://www.malteahrens.com/blog/scibot-the-beginning/</link>
		<comments>http://www.malteahrens.com/blog/scibot-the-beginning/#comments</comments>
		<pubDate>Mon, 24 Sep 2012 12:31:55 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robots]]></category>
		<category><![CDATA[scibot]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=625</guid>
		<description><![CDATA[Ever since I was eight, one of my earliest memories of self-consciousness, I have dreamt of cars that drive themselves, where you could turn your seat towards the center and play a game of cards while travelling (entertainment those days!). I believed that by the time I&#8217;d be old enough to take control of the [...]]]></description>
				<content:encoded><![CDATA[<p>Ever since I was eight, one of my earliest memories of self-consciousness, I have dreamt of cars that drive themselves, where you could turn your seat towards the center and play a game of cards while travelling (entertainment those days!). I believed that by the time I&#8217;d be old enough to take control of the wheel, I would no longer need to. </p>
<p>When I was thirteen, it became pretty clear to me that this would not happen in time, and I began questioning whether we&#8217;d actually achieve this in my own lifetime.</p>
<p>Now, a couple of years later, having been astonished by how far Google is with their self-driving Prius (and now <a href='http://www.wired.com/autopia/2012/04/google-autonomous-lexus-rx450h/' target="_blank">Audi TT&#8217;s and Lexus RH450h&#8217;s</a> as well), empowered by Sebastian Thrun&#8217;s <a href='http://www.udacity.com/overview/Course/cs373' target="_blank">Programming a Robotic Car</a> course, and supported by my high school, I have been working a self-driving car of my own. </p>
<p>Taking on passengers might take some more time, though.</p>
<p><iframe width="853" height="480" src="http://www.youtube.com/embed/XhhS-UDat7Y?rel=0" frameborder="0" allowfullscreen></iframe><br />
Sequences have been <i>lengthened</i> &#8211; the actual computation time for updating the probabilities after <i>move</i> and <i>sense</i> is ~6ms each. It&#8217;s moving the robot that takes time.</p>
<p><b>sci-bot</b>: <i>noun</i> A knowing / self-aware robot. From the Latin <a target="_blank" href='http://en.wiktionary.org/wiki/scio#Latin'>sciō</a> + Czech <a href='http://en.wiktionary.org/wiki/robot' target="_blank">robot</a></p>
<h1>The guts</h1>
<p><a target="_blank" style='border:none;float:left;margin-top:-15px;padding-right:10px' id='rss' href='http://www.malteahrens.com/blog/wp-content/uploads/2012/09/robo.jpg'><img style='width:300px' src='http://www.malteahrens.com/blog/wp-content/uploads/2012/09/robo.jpg' /></a></p>
<p><b>iRobot Create (from <a target="_blank" href='http://store.iheartengineering.com/iRobot-Create%C2%AE-Programmable-Battery-Charger/dp/B007EE66S0'>iheartengineering.com</a>)</b><br />
The Create is a decently priced platform (about $200) to base a robot on. Given that it is simply a Roomba without the vacuum cleaner guts means that you get a reliable, tested, and complete system (from battery recharging to motors) with a decent <a target="_blank" href='http://www.irobot.com/filelibrary/pdfs/hrd/create/create%20open%20interface_v2.pdf'>programming interface</a>.</p>
<p>Zach Dodds et al. from the <a target="_blank" href='http://www.rose-hulman.edu/class/csse/resources/Robotics/'>Rose-Hulman Institute of Technology</a> has written a brilliant python wrapper for the Create&#8217;s serial interface. I use it because it simplifies commands like move forward at 25cm/s rotating at 30°/s from:
<div style='font-family:"Courier New", Courier, monospace;display:inline'>137 0 250 1 221</div>
<p>to the more intelligible:
<div style='font-family:"Courier New", Courier, monospace;margin-bottom:70px'>robot.go(25, 30)</div>
<p><b>Laptop</b><br />
The laptop acts as the middle man between the sensors and the robot, the brain some might say, interpreting the sensor data (the robot &#038; LIDAR sensor just plug in over USB) and giving directions to the robot. </p>
<p><b>Hokuyo URG-04LX URG01 Laser (from <a target="_blank" href='http://www.hokuyo-aut.jp/02sensor/07scanner/urg_04lx_ug01.html'>Hokuyo</a>)</b><br />
While not exactly cheap at $1200, a LIDAR (short for Light Detection and Ranging) provides extremely accurate (around ±1 cm, though the URG01 is limited by Hokuyo to ±3 cm) distance information. Measuring distance given the <a target="_blank" href='http://en.wikipedia.org/wiki/Laser_rangefinder#Calculation'>change in phase of a reflected light wave</a> it operates similarly to radar (though radar, using radio waves, is further along the electromagnetic spectrum). Using light rather than sound it is both quicker (after all you hear sound echo, but on a normal human scale don&#8217;t see light echo), less prone to interference and works over longer distances (military rangefinders reach 25km!) than say an ultrasound sensor. It may be overkill for a basic robot, but it becomes integral for advancing the robot.<br />
<a target="_blank" id='rss' style='float:right;width:300px;border:none;padding-left:10px;margin-top:20px' href='http://www.malteahrens.com/blog/wp-content/uploads/2012/09/Lidar-and-map.png'><img src='http://www.malteahrens.com/blog/wp-content/uploads/2012/09/Lidar-and-map.png' /></a></p>
<p>The URG01 provides a 5.6m range over 240° (for reference, the Xbox Kinect sees about <a target="_blank" href='http://kotaku.com/5576002/here-are-kinects-technical-specs'>55°</a>) for 683 points along it&#8217;s rotation (it&#8217;s a laser diode and photo detector that rotate). Rotating at 10Hz (10 times a second) it provides about 6000 data points per second. Weighing 160g, it&#8217;s perfect for this application.</p>
<p><i>right</i> is what the LIDAR sees in our hallway at home, with an outline of the hallway overlayed (one circle is 1m).</p>
<p>Consider it a tiny version of the LIDAR that&#8217;s used for Google&#8217;s cars and <a target="_blank" href="http://www.theverge.com/2012/7/14/3157401/mit-intelligent-co-pilot-car">self-driving vehicle</a> <a target="_blank" href="http://web.mit.edu/ster/www/documents/IV2012_Anderson.pdf">research</a>&#8230;1.3 million data points / second&#8230;Wow!<br />
<iframe src="http://blip.tv/play/7m7RrjEC.html?p=1" width="550" height="443" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#7m7RrjEC" style="display:none"></embed><br />
<a target="_blank" href='http://www.hizook.com/blog/2009/01/04/velodyne-hdl-64e-laser-rangefinder-lidar-pseudo-disassembled'>Velodyne HDL-64E Laser Rangefinder (LIDAR) Pseudo-Disassembled</a></p>
<h1>The brains</h1>
<p>The robot uses basic <a target="_blank" href='http://en.wikipedia.org/wiki/Monte_Carlo_localization'>Mote-Carlo localization</a> (a histogram filter) to find out where it is at that moment in time. In other words, given a grid based map of the environment, the code will use probabilities to work out in which cell (or part of the map) it is likely to be. Given that this requires there to be a preexisting map of the world in which the robot is, it is not fully <i>autonomous</i>, or able to make decisions when things happen that you do not expect to happen (for example, somebody is standing in the hallway).</p>
<p>Anyway, it starts by having a map of environment, in this case our hallway at home represented by 1m² squares, or cells. Not only does the robot not know <i>where</i> it is, but it also doesn&#8217;t know in <i>which direction</i> it is facing &#8211; this becomes a big problem if you tell the robot to drive forward because you think its position is aligned with the North map, but it might actually be facing East, so it hit&#8217;s a wall&#8230; To counter this, there are four maps, one for each direction North, East, South, and West &#8211; in the East one, for example, we assume the robot is facing East, in the South one, we assume South, etc.</p>
<p>Since the robot has no idea where it is or what direction is is facing when it starts, each cell begins with the same probability of 2.8% (1 ÷ (9 cells × 4 orientations)):</p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">2.8%</td>
<td style="width:50px;border-right:3px solid black;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">2.8%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">2.8%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">2.8%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">North</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">2.8%</td>
<td style="width:50px;border-right:3px solid black;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">2.8%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">2.8%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">2.8%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">East</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">2.8%</td>
<td style="width:50px;border-right:3px solid black;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">2.8%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">2.8%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">2.8%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">South</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">2.8%</td>
<td style="width:50px;border-right:3px solid black;">2.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">2.8%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">2.8%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">2.8%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">2.8%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">West</b>
        </td>
</tr>
</table>
<p>Next, we take a look at what the sensor sees. In this case, say it it sees a wall to the left, space in front, and a wall to the right (in the code I&#8217;ve written, that is represented as [1, 0, 1]). With this new data, we can now cycle through all the cells and if this sensor measurement is what we&#8217;d expect at that location and orientation, we increase it&#8217;s probability, and if it is not, we decrease it. So this is what we get after the first <i>sense</i>:</p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.5%</td>
<td style="width:50px;border-right:3px solid black;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.5%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.5%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">North</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.5%</td>
<td style="width:50px;border-right:3px solid black;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0.5%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.5%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.5%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">East</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.5%</td>
<td style="width:50px;border-right:3px solid black;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">8.8%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.5%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.5%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">South</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.5%</td>
<td style="width:50px;border-right:3px solid black;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0.5%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.5%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;background:#FFF2CC;">8.8%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">West</b>
        </td>
</tr>
</table>
<p>And we see that it is unlikely that we&#8217;re facing East &#8211; after all, there is not a cell (facing east) in which we&#8217;d expect such a sensor reading.</p>
<p>Next up, we move the actual robot (after all, what use is it stationary?). The measurements from the LIDAR told us there is space ahead, so we move forward. If we can move to a particular cell, its probability becomes the probability of the cell that we moved from plus the probability that it stays on that cell (the robot&#8217;s movement is not perfect, so to factor that in, we add the (unlikely at about 10% &#8211; a value that I (somewhat arbitrarily) made up) chance that it doesn&#8217;t move). So, probabilities are shifted around and are changed a bit depending on whether we can move to a cell, or whether the robot breaks down. This forward movement then gives us:</p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px;background:#FFF2CC;">8.7%</td>
<td style="width:50px;border-right:3px solid black;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;background:#FFF2CC;">9.6%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">9.6%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">9.6%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1.4%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.1%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.1%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">North</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.1%</td>
<td style="width:50px;border-right:3px solid black;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0.1%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.1%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.5%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">East</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.1%</td>
<td style="width:50px;border-right:3px solid black;background:#FFF2CC;">8.7%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">1.4%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">9.6%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">9.6%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFF2CC;">9.6%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;background:#FFF2CC;">8.7%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.1%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">South</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.5%</td>
<td style="width:50px;border-right:3px solid black;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0.1%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;background:#FFF2CC;">8.7%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">1%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">West</b>
        </td>
</tr>
</table>
<p>Note how the probabilities have shifted and changed slightly.</p>
<p>Once we have a map (the first step, where each cell has a uniform probability) we just loop through <i>sense()</i> and then <i>move()</i> until we&#8217;ve either reached our destination or are happy with the result. So next there&#8217;s <i>sense</i> again with a reading, say, wall to the left, wall in front, and space to the right or [1, 1, 0]:</p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px;background:#FFE699;">28.9%</td>
<td style="width:50px;border-right:3px solid black;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">1.7%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1.7%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1.7%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">North</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0</td>
<td style="width:50px;border-right:3px solid black;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.1%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">East</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0</td>
<td style="width:50px;border-right:3px solid black;background:#FFE699;">28.9%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0.2%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1.7%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1.7%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">1.7%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">1.5%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.2%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">South</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.1%</td>
<td style="width:50px;border-right:3px solid black;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;background:#FFE699;">28.9%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.2%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">West</b>
        </td>
</tr>
</table>
<p>So, now there are three points where we&#8217;re (equally) likely to be. To improve the accuracy, we continue the loop with a <i>move</i>. This time, however, with the reading from the lidar saying that the only free space is to the right, we need to turn the robot 90° to the right, and <i>then</i> move forward. Since we change orientation, we need to move the maps as well. In this case, we turn right, so all the probabilities of the North map become the East map, all the probabilities of the East map becomes the South map, and so on. After the map turning, we just apply the normal <i>move</i> updating of probabilities &#8211; shift them and update them to include the chance of a failed move: </p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px;">0</td>
<td style="width:50px;border-right:3px solid black;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFE699;">29.4%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">3.3%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">North</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">3.3%</td>
<td style="width:50px;border-right:3px solid black;background:#FFE699;">29.4%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0.2%</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">East</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0</td>
<td style="width:50px;border-right:3px solid black;">0.2%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">South</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px;background:#FFE699;">29.4%</td>
<td style="width:50px;border-right:3px solid black;">3.3%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0.2%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;b">0.3%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">West</b>
        </td>
</tr>
</table>
<p>Continuing the loop, there is <i>sense</i> again with say, wall to the left, space in front, and wall to the right or [1, 0, 1] and we get the <i>wonderful</i> result of:</p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px;">0</td>
<td style="width:50px;border-right:3px solid black;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;background:#FFC000;font-weight:bold;">88.5%</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0.5%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">North</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0.5%</td>
<td style="width:50px;border-right:3px solid black;">4.7%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">East</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px">0</td>
<td style="width:50px;border-right:3px solid black;">0.1%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;">0</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">South</b>
        </td>
<td style="width:180px;text-align:center">
<table style="border-spacing:0;text-align:center;display:inline-table">
<tbody>
<tr style="height:50px">
<td style="border-right:3px solid black;border-bottom:3px solid black;"></td>
<td style="border-top:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:1px dotted gray;width:50px;">4.7%</td>
<td style="width:50px;border-right:3px solid black;">0.5%</td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;border-top:1px dotted gray;">0</td>
<td style="border-top:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-right:3px solid black;border-bottom:1px dotted gray;">0</td>
<td style="border-bottom:3px solid black;"></td>
</tr>
<tr style="height:50px">
<td style="border-left:3px solid black;border-bottom:3px solid black;border-right:1px dotted gray;b">0.1%</td>
<td style="border-right:3px solid black;border-bottom:3px solid black;">0.1%</td>
</tr>
</tbody>
</table>
<p>            <b style="display:block;">West</b>
        </td>
</tr>
</table>
<p>and there, after moving only 2 meters, the robot has a pretty decent idea of where it is and which way it is heading. If only the <i>real</i> world were so easy!</p>
<p>You may notice that the movement in this case was the same as in the video earlier. You might also have noticed that we got slightly different results this time round. The reason for this, is that for some reason (I&#8217;m still not sure myself) the robot sensed that there&#8217;s nothing in the way or [0, 0, 0] instead of wall to the left, space in front, and a wall to the right or [1, 0, 1] right at the start. Thus, since [0, 0, 0] isn&#8217;t something we&#8217;d expect so see anywhere in the map, we lost that first piece of information and just moved forward without <i>sense</i> updating the probabilities. It is because of this (the sensor is sometimes wrong), that there&#8217;s also a factoring of the sensor data, though it is unlikely (I guessed it at 1%) that this will happen. </p>
<p>In retrospect, I suspect it might be because the LIDAR was still turning on, and since it runs in a separate process (on a separate core), the code didn&#8217;t realize that. Something that needs investigating.</p>
<p>Another pattern that you may have picked up, is that while <i>sense</i> adds information, the <i>move</i> function will sometimes make you lose information. This happens when the robot is driving up the straight part of the hallway (again, in the video) and is 83.2% sure that it that cell at the beginning, but by the end of the corridor, this drops to 64.8%. This because moving is far less reliable than sensing, so when we move in a straight corridor we begin to lose information. That&#8217;s not to say that <i>move</i> can&#8217;t add information, though &#8211; for example when turning corners (corners are <i>fantastic</i> for localization!).</p>
<p>Thankfully, computers exist to do all this menial computation for us, and to change this from a theoretical learning task to a practical application one, I&#8217;ve written this all up in python (3.2). The full code is available on GitHub: <a target="_blank" href='https://github.com/ahrensmalte/scibot'>https://github.com/ahrensmalte/scibot</a> and you don&#8217;t need a robot, gyroscope, or lidar to run it! (the localisation)</p>
<p>A few notes about the code though:</p>
<ul>
<li>The lidar data gathering and interpreting runs in a separate process (<i>not</i> thread) to improve performance &#8211; most computers these days have more than one core, so why not use it? This means, however, that all serial communications, and so, need to run in that process, alas the readability and debuggability is somewhat affected. The performance improvements, however, I believe are worthwhile &#8211; cutting down time between computation and moving the robot from 1 second to <i>almost</i> instant (it still stutters though because it&#8217;s not a continuous map and planning, but discrete)</li>
<li>Gyroscope accuracy still leaves something to be desired (even after temperature calibrating it each time the robot is turned on &#8211; see <a target="_blank" href="https://github.com/ahrensmalte/scibot/blob/master/sensors.py#L62">sensors.py</a>)</li>
</ul>
<h2 style="margin-top:30px">What&#8217;s next?</h2>
<ul>
<li>Taking the robot into a different (read more complicated) environment and seeing how it handles there</li>
<li>Using multiple sensor inputs to provide a more accurate output &#8211; for example using both the inbuilt wheel encoders and the gyroscope to measure turns (the gyroscope does not always pick up the start of the turn while the robot is still accelerating (linearly, nor radially) though is very accurate once it is in motion and the wheel encoders which aren&#8217;t precise, but do provide a rough guess)</li>
<li>Implementing <a target="_blank" href="http://en.wikipedia.org/wiki/A_star">A*</a> (pronounced <i>a star</i>) so that once the probability is above, say, 90% the robot turns around and heads back to it&#8217;s &#8216;home&#8217; location</li>
<li>Changing the current binary sensor output (wall-or-not) to a staggered one, which would allow the robot to traverse areas that don&#8217;t have at least two walls at each position &#8211; this would also allow the grid resolution to increase (the hallway, being 1m wide, was perfect for this basic implementation) so you&#8217;d get some more <i>creative</i> paths since there&#8217;s more than 9 places where the robot can be</li>
<li>Using path smoothing for more&#8230;<i>elegant</i> turns</li>
<li>Looking at more advanced Mote-Carlo localization implementations, like the ones discussed in <a target="_blank" href='http://www.ri.cmu.edu/pub_files/pub1/dellaert_frank_1999_2/dellaert_frank_1999_2.pdf'>this paper</a> from Frank Dellaert, Dieter Fox, Wolfram Burgard, and Sebastian Thrun</li>
<li>and of course, an implementation where the robot can be in a completely new environment, and map it. <a target="_blank" href='http://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping'>SLAM</a> (Simultaneous Localization And Mapping) comes to mind, though landmark detection is probably going to be the challenge &#8211; their&#8217;s <a target="_blank" href='http://en.wikipedia.org/wiki/RANSAC'>RANSAC</a> (RANdom SAmple Consensus) and a couple of other landmark detection algorithms</li>
</ul>
<p><i style='padding-top:30px;display:block'>endnote: To CS373 roboticist&#8217;s reading this, the process of physically implementing what we learn (this probably applies to all education) adds a whole new level of understanding to what we do in class &#8211; I highly recommend it.</i><br />
<i style='margin-top:-10px;display:block'> and to those you prefer the names Robo, Robert, Robotina, or Robbie (did I spell that right?): sorry, I used the gender equal and more ambiguous (perhaps derogatory though?) name scibot here instead. To those who enjoy playing cards: sorry, I actually do too.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/scibot-the-beginning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Vicious Cycle</title>
		<link>http://www.malteahrens.com/blog/the-vicious-cycle/</link>
		<comments>http://www.malteahrens.com/blog/the-vicious-cycle/#comments</comments>
		<pubDate>Mon, 16 Jul 2012 15:14:40 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[Statistics]]></category>
		<category><![CDATA[World Issues]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=565</guid>
		<description><![CDATA[With the London Summit on Family Planning last Wednesday, a flurry of statistics and tweets came my way. Not knowing a great deal about family planning in other regions of the world, or the importance of the $2.6 bilion dollar&#8217;s worth of commitments announced, I decided to investigate. Note: All charts are interactive, so grab [...]]]></description>
				<content:encoded><![CDATA[<p>With the <a target='_blank' href='http://www.londonfamilyplanningsummit.co.uk/'>London    Summit on Family Planning</a> last Wednesday, a flurry of statistics and tweets came my way. Not knowing a great deal about family planning in other regions of the world, or the importance of the <a href='http://www.londonfamilyplanningsummit.co.uk/1530%20CommitmentSummary_Final_.pdf'    target="_blank">$2.6 bilion</a> dollar&#8217;s worth of commitments announced, I decided to investigate.</p>
<p><i>Note:</i> All charts are interactive, so grab your mouse and hover over them!        Also, you can download a <a id='rss' href='http://www.malteahrens.com/blog/wp-content/uploads/2012/07/The-Vicious-Cycle.pdf' target="_blank">PDF copy here</a>.<br />
<hr />To begin, let&#8217;s take a look at the legal age for marriage, the earliest that you can marry without requiring parental and/or judicial approval (it depends on the state / country).
<div id='marriage' style='padding-bottom: 15px'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Minimum legal age for marriage without consent</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a19'>United        Nations Statistics Division Gender Info 2007</a>
<div id="marriage_chart" style="width: 900px"></div>
<div style='font-size:small;color:gray'>-1 denotes no information</div>
</div>
<p><b>Countries with a minimum legal age for marriage (women) below 18 years (per <a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a19'>UNSD, Gender Info 2007</a>):</b><br />
<table style='width: 900px;'>
<tr>
<td> Andorra &#8211; 16 (2001) </td>
<td> Argentina &#8211; 16 (2002) </td>
<td> Armenia &#8211; 17 (2002) </td>
<td> Austria &#8211; 16 (2003) </td>
</tr>
<tr>
<td> Azerbaijan &#8211; 17 (2007) </td>
<td> Barbados &#8211; 16 (2002) </td>
<td> Benin &#8211; 15 (2005) </td>
<td> Bolivia &#8211; 14 (1995) </td>
</tr>
<tr>
<td> Burkina Faso &#8211; 17 (2005) </td>
<td> Cameroon &#8211; 15 (2000) </td>
<td> Congo Dem. Rep. &#8211; 15 (2006) </td>
<td> Costa Rica &#8211; 15 (2003) </td>
</tr>
<tr>
<td> Dominica &#8211; 16 (2003) </td>
<td> Egypt &#8211; 16 (2003) </td>
<td> Equatorial Guinea &#8211; 12 (2004) </td>
<td> Gabon &#8211; 15 (2005) </td>
</tr>
<tr>
<td> The Gambia &#8211; <i>none</i> (2005) </td>
<td> Guinea &#8211; 17 (2007) </td>
<td> Indonesia &#8211; 16 (2007) </td>
<td> Iran &#8211; 15 (2003) </td>
</tr>
<tr>
<td> Israel &#8211; 17 (2003) </td>
<td> North Korea &#8211; 17 (2005) </td>
<td> South Korea &#8211; 16 (2007) </td>
<td> Kuwait &#8211; 15 (2004) </td>
</tr>
<tr>
<td> Luxembourg &#8211; 16 (1997) </td>
<td> Maldives &#8211; <i>none</i> (2001) </td>
<td> Mali &#8211; 15 (2006) </td>
<td> Mexico &#8211; 14 (2006) </td>
</tr>
<tr>
<td> Mozambique &#8211; 14 (2007) </td>
<td> Niger &#8211; 15 (2007) </td>
<td> Pakistan &#8211; 16 (2007) </td>
<td> Paraguay &#8211; 16 (2005) </td>
</tr>
<tr>
<td> Peru &#8211; 16 (2007) </td>
<td> Portugal &#8211; 16 (2003) </td>
<td> Republic of Moldova &#8211; 16 (2006) </td>
<td> Romania &#8211; 16 (2006) </td>
</tr>
<tr>
<td> Saudi Arabia &#8211; 17 (2003) </td>
<td> Thailand &#8211; 17 (2006) </td>
<td> Togo &#8211; 17 (2006) </td>
<td> Turkey &#8211; 17 (2005) </td>
</tr>
<tr>
<td> Uganda &#8211; 16 (2003) </td>
<td> Ukraine &#8211; 17 (2003) </td>
<td> Uzbekistan &#8211; 17 (2006) </td>
<td> Vanuatu &#8211; 16 (2007) </td>
</tr>
<tr>
<td> Venezuela &#8211; 14 (2006) </td>
<td> Yemen &#8211; 15 (2002) </td>
</tr>
</table>
<p>That is 46 countries with a legal marriage age under 18 years, but is this illegal under International Law?</p>
<p>Under the <a href='http://www.un.org/en/documents/udhr/' target='_blank'>Universal Decleration of Human    Rights</a> (1948):
<div style='margin: 0px 30px;border: 1px solid black;padding: 5px;'><b>Article 16.</b>
<ol style='padding-right: 10px;'>
<li>Men and women of full age, without any limitation due to race, nationality or religion, have the right to marry and to found a family. They are entitled to equal rights            as to marriage, during marriage and at its dissolution.</li>
<li>Marriage shall be entered into only with the free and full consent of the intending            spouses.</li>
<li>The family is the natural and fundamental group unit of society and is entitled            to protection by society and the State.</li>
</ol>
</div>
<p>and elaborated in the <a href='http://www2.ohchr.org/english/law/crc.htm' target='_blank'>Convention    on the Rights of the Child</a> (1990):
<div style='margin: 0px 30px;border: 1px solid black;padding: 5px;'><b>Article 1.</b><br />For the purposes of the present Convention, a child means every human being below    the age of eighteen years unless under the law applicable to the child, majority    is attained earlier.</div>
<p>the UN clearly recommends the minimum age of marriage to be 18. Individual countries, however, can still set their own age (<a href='http://www.un.org/cyberschoolbus/humanrights/qna/elsa.asp'  target='_blank'>un.org</a>). So, in a country like Niger where marriage under 18 (minimum age of 15) is allowed, provided the child, the parents, and a judge agree, child marriage is legal.</p>
<p>Unfortunately, in most cases it doesn&#8217;t happen that way, and be it due to poverty, tradition, or gender (in)equality (<a href='http://girlsnotbrides.org/child-marriage/' target='_blank'>Girls    not brides</a>) children are forcibly married.</p>
<p>But, does this just happen in countries with such a low legal minimum age?
<div id='marriage-legalvsmean'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Comparing the legal minimum age of marriage to the average age at marriage</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a19'>United        Nations Statistics Division Gender Info 2007</a> and <a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a20'> United Nations Statistics Division Gender Info 2007</a>
<div id="marriagecomp_chart" style="width: 900px;height: 500px"></div>
</div>
<p>There appears to be a correlation between the legal minimum age and the average age of marriage, however it is not necessarily clear whether this is a causation (<i>cum hoc ergo propter hoc</i>). If we limit the data to just Africa, however, a slightly smaller subset of global cultures, we see that this correlation continues, suggesting that the age at marriage is affected by the legal minimum age and not just external factors like tradition or culture.</p>
<p>Once the legal age is above 18, though, this effect is less pronounced.
<div id='marriage-legalvsmean-africa'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Comparing the legal minimum age of marriage to the average age at marriage for just        Africa</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a19'>UNSD        Gender Info 2007</a> and <a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a20'> UNSD Gender Info 2007</a>
<div id="merriagecomp_chart_africa" style="width: 900px;height: 500px"></div>
</div>
<p>Interesting to note, is that the countries: Nepal (legal age: 20), Papua New Guinea (legal age: 21), and Sierra Leone (legal age: 21) all have an average age when married <i>below</i> their respective legal ages (19 vs. 20 for Nepal, 20.8 vs 21 for Papua New Guinea, and 19.8 vs 21 for Sierra Leone). There is clearly something going on there&#8230;the rule of law does not necessarily play such a guiding force as we might have thought.</p>
<p>Conversely, as the red line (denoting an average age at marriage of 18) suggests with only Niger at 17.6 years (1998) and Saw Tome and Principe at 17.8 years (1997) having an average age under 18 years, regardless of the law, the average marriage age is almost-universally above 18, i.e. not child marriage.</p>
<p>But all these inferences need to be kept in context: we are just looking at the average ages here, something that can very easily be distorted by a couple (relatively speaking) of outliers. There is another statistic, however, that we can look at, the proportion of women now aged 20 to 24 that were married when they were still children.
<div id='marriage-child20to24' style='padding-bottom: 15px'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Child marriage among women aged 20-24</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a21'>United        Nations Statistics Division Gender Info 2007</a>
<div id="marriagechild20to24_chart" style="width: 900px"></div>
<div style='font-size:small;color:gray'>-1 denotes no information</div>
</div>
<p>Combining this dataset (which, admittedly, doesn&#8217;t have each country&#8217;s figures for 2011 &#8211; Liberia&#8217;s stats come from 1986!) with data from the <a target='_blank' href='http://www.census.gov/population/international/data/idb/informationGateway.php'> US Census</a> for that year, we can work out a rough number of women 20-24 who were married as children.<br />
<h3 style='margin-bottom: -5px'> Countries sorted by number of women 20-24 who were married as children</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a21'>United    Nations Statistics Division Gender Info 2007</a> and <a target='_blank' href='http://www.census.gov/population/international/data/idb/informationGateway.php'> US Census</a><br />
<table style='width: 900px;border-spacing: 0;margin-top: 2px'>
<tr>
<td style='border-bottom: 1px solid black'><b>Country</b></td>
<td style='border-bottom: 1px solid black'><b>Legal Age of Marriage</b></td>
<td style='border-bottom: 1px solid black'><b>Child marriage among women 20-24</b></td>
<td style='border-bottom: 1px solid black;border-left: 2px solid black;'><b>Number of women married as children</b></td>
</tr>
<tr>
<td> India        </td>
<td> 18 (2003) </td>
<td> 46% (1999) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 20.7 million        </td>
</tr>
<tr>
<td> Bangladesh        </td>
<td> 18 (2003) </td>
<td> 65% (1999) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 4.1 million        </td>
</tr>
<tr>
<td> Nigeria        </td>
<td><i>no data</i></td>
<td> 43% (2003) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 2.6 million        </td>
</tr>
<tr>
<td> Indonesia        </td>
<td> 16 (2003) </td>
<td> 24% (2002) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 2.5 million        </td>
</tr>
<tr>
<td> Brazil        </td>
<td> 21 (2004) </td>
<td> 24% (1996) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 1.8 million        </td>
</tr>
<tr>
<td colspan='4' style='text-align: center;'> &#8230;        </td>
</tr>
<tr>
<td></td>
<td></td>
<td style='text-align: right'> Total:        </td>
<td style='padding-left: 2px'><b>47.4 million</b></td>
</tr>
</table>
<p>The <a target='_blank' href='http://www.girleffect.org/blog/2012/07/11/family-planning-unleashes-the-girl-effect/'> Girl Effect</a> and <a target='_blank' href='http://girlsnotbrides.org/child-marriage/'> Girls not brides</a> quote that around 10 million girls aged under 18 are married worldwide every year. Staggeringly, even with this limited dataset (both in terms of countries and up-to-date<i>ness</i>) we get a similar figure &#8211; with 47.4 million women who were married as kids over 5 years of data (ages 20, 21, &#8230; 24), a number that we assume to stay &#8216;steady&#8217;, therefore as every year one &#8216;year&#8217; leaves this dataset and a new one comes, we can only assume that around <b>9.54 million    girls become new child brides every year.</b></p>
<p>10 million girls every year.</p>
<p>Originally, we looked at the impact that the legal age has on the average age at marriage, and we found a general trend that a higher legal age brings a higher average age. This new data, however, shows that <b>71% of these 10 million child brides &#8211; that&#8217;s    6.8 million girls &#8211; live in countries where the minimum legal age for marriage is    at or above 18.</b></p>
<p>The law, clearly, doesn&#8217;t have the sort of impact that it should, and that we need it to have. Additionally, even in countries with a legal age under 18, for example Uzbekistan at 13% (2001), Armenia at 19% (2000), or Turkey at 23% (1998), all with a legal age of 17 (2003, 2004, 2007 respectively) the rate of child marriage is acutely lower than that of Bangladesh at 65% (1999) or Nepal at 56% (2001) both with legal age at or above 18 (18 (2003) and 20 (2001) respectively).</p>
<p>Yet with or without law, the horrors still continue.</p>
<p>With child marriage, comes a great difficulty for the child to abstain from sex, or insist on condom use and such, they are exposed to serious health risks such as premature pregnancy, sexually transmitted infections, and increasingly, HIV/AIDS (<a href='http://www.unicef.org/protection/files/Child_Marriage.pdf' target='_blank'>UNICEF    Child Protection Information Sheet</a>).</p>
<p>A trend that is clear when looking at the adolescent fertility rate, the number of births per 1,000 women aged 15 to 19.
<div id='adolescentfertility-geo'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Adolescent fertility rate (births per 1,000 women ages 15-19), 2010</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=WDI&#038;f=Indicator_Code%3aSP.ADO.TFRT'> World Bank World Development Indicators</a>
<div id="adolescentfertilitygeo_chart" style="width: 900px"></div>
</div>
<p>If we limit the data to the five countries with the highest rate of child marriage, this relation is definite.<br />
<h3 style='margin-bottom: -5px'> Women 20-24 who were married as children, Adolescent fertility rate</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a21'>UNSD    Gender Info 2007</a> and <a target='_blank' href='http://data.un.org/Data.aspx?d=WDI&#038;f=Indicator_Code%3aSP.ADO.TFRT'> World Bank World Development Indicators</a><br />
<table style='width: 900px;border-spacing: 0;margin-top: 2px'>
<tr>
<td style='border-bottom: 1px solid black'><b>Country</b></td>
<td style='border-bottom: 1px solid black'><b>Child marriage among women 20-24</b></td>
<td style='border-bottom: 1px solid black;border-left: 2px solid black;'><b>Adolescent fertility rate (births / 1,000 women)</b></td>
</tr>
<tr>
<td> Niger        </td>
<td> 77% (1998) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 199 (2010) </td>
</tr>
<tr>
<td> Chad        </td>
<td> 71% (1997) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 145 (2010) </td>
</tr>
<tr>
<td> Bangladesh        </td>
<td> 65% (1999) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 73 (2010) </td>
</tr>
<tr>
<td> Guinea        </td>
<td> 65% (1999) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 143 (2010) </td>
</tr>
<tr>
<td> Mali        </td>
<td> 65% (2001) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 176 (2010) </td>
</tr>
<tr>
<td colspan='4' style='text-align: center;'> &#8230;        </td>
</tr>
</table>
<p>Niger, Chad, Guinea, and Mali, all countries with staggeringly high rates of child marriage, make up the four highest rates of adolescent births.</p>
<p>With the asymmetric power complex of a child marriage, it can only amplify any traditional or religious reluctance towards the use of contraceptives, the same contraceptives that would protect against premature pregnancy (which can create health complications in both mother and child, <a href='http://wwwnc.cdc.gov/eid/article/12/11/06-0510_article.htm' target='_blank'> CDC</a>), malaria (the risk increases during pregnancy, especially when the mother is under 19, <a href='http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2672998/' target='_blank'>National    Institutes of Health</a>) and sexually transmitted infections. As is shown when looking at contraceptive use around the world.<br />
<table style='margin-top: 15px;margin-bottom: 15px;'>
<tr>
<td style="width: 450px">
<div id='contraceptives'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Contraceptive prevalence rate, women 15-49</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=SOWC&#038;f=inID%3a34'>UNCF The State                    of the World’s Children 2006-2010</a>
<div id="contraceptives_chart" style="width: 450px"></div>
</div>
</td>
<td style="width: 450px">
<div id='unmet'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Unmet needs for family planning</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=MDG&#038;f=seriesRowID%3a764'>UNSD                    Millennium Development Goals Database</a>
<div id="unmetcontraceptives_chart" style="width: 450px"></div>
</div>
</td>
</tr>
</table>
<p>Countries that have unmet needs for family planning, for contraceptives, are largely those that have the lowest contraceptive prevalence rate. When you sum the rate of use with the unmet needs for family planning, you get the proportion of people that are either using, or would like to use contraceptives. Surprisingly, this number is largely stable throughout different regions in the world, averaging at about 70%.
<div id='contraceptives-sum'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Percentage of people that either use, or would like to use, contraceptives</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=SOWC&#038;f=inID%3a34'>UNCF The State        of the World’s Children 2006-2010</a> and <a target='_blank' href='http://data.un.org/Data.aspx?d=MDG&#038;f=seriesRowID%3a764'> UNSD Millennium Development Goals Database</a>
<div id="sumcontraceptives_chart" style="width: 900px"></div>
</div>
<p>Stable, that is, (largely) everywhere except Sub-Saharan Africa (a lot of countries aren&#8217;t in the <i>Millennium Development Goals Database</i> for <i>Unmet needs for family    planning</i> and such, they aren&#8217;t represented in this) where the rate stands around 40%, a lot lower than the average, and even lower than that of developed countries.</p>
<p>This is as we inferred, these Sub-Saharan countries, particularly Mali, Niger, and Chad, the same ones that have high rates of child marriage, and child fertility, dominate as countries with a low use of contraceptives and unmet needs. Right here looks to be one of the places where an increased (education, acceptance, and) use of contraceptives would be most useful in preventing this cascading chain, starting with chain marriage, from continuing.</p>
<p>When girls get married, particularly if they have a child to care for as well, they are likely to drop out of school. Even worse, with this lack of contraceptives, their own children may themselves struggle with their education (<a href='http://www.guardian.co.uk/world/2012/jul/11/melinda-gates-challenges-vatican-contraception' target='_blank'>Melinda    Gates</a>) &#8211; with an increase in the number of children, so does the difficulty in feeding them all increase. This continues to be represented in our own data (note the correlation between countries with a low secondary school enrollment (which is around when puberty starts, which is around the age that children are married at &#8211; though some are as young as 7 (<a href='http://www.washingtonpost.com/world/africa/in-niger-hunger-crisis-raises-fears-of-more-child-marriages/2012/07/09/gJQA8xD9YW_story.html'    target="_blank">Washington Post</a>) and a high rate of child marriage).<br />
<table style='margin-top: 15px;margin-bottom: 15px;'>
<tr>
<td style="width: 450px">
<div id='primaryeducation-geo'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Primary School enrollment ratio (for girls)</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=UNESCO&#038;f=series%3aNER_1'>UNESCO                    Primary education (ISCED 1) Net enrolment rate</a>
<div id="primaryeducationgeo_chart" style="width: 450px"></div>
</div>
</td>
<td style="width: 450px">
<div id='secondaryeducation-geo'>
<h3 style='margin-bottom: 0px;padding-bottom: 0px'> Secondary School enrollment ratio (for girls)</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=UNESCO&#038;f=series%3aNER_23'>UNESCO                    Total Secondary Net enrolment rate</a>
<div id="secondaryeducationgeo_chart" style="width: 450px"></div>
</div>
</td>
</tr>
</table>
<p>
<h3 style='margin-bottom: -5px'> Women 20-24 who were married as children, Primary &#038; Secondary Enrollment rates</h3>
<p><a target='_blank' href='http://data.un.org/Data.aspx?d=GenderStat&#038;f=inID%3a21'>UNSD    Gender Info 2007</a> and UNESCO <a target='_blank' href='http://data.un.org/Data.aspx?d=UNESCO&#038;f=series%3aNER_1'> Primary education (ISCED 1) Net enrolment rate</a>, <a target='_blank' href='http://data.un.org/Data.aspx?d=UNESCO&#038;f=series%3aNER_23'> Total Secondary Net enrolment rate</a><br />
<table style='width: 900px;border-spacing: 0;margin-top: 2px'>
<tr>
<td style='border-bottom: 1px solid black'><b>Country</b></td>
<td style='border-bottom: 1px solid black'><b>Child marriage among women 20-24</b></td>
<td style='border-bottom: 1px solid black'><b>Primary enrollment</b></td>
<td style='border-bottom: 1px solid black;border-left: 2px solid black;'><b>Secondary enrollment</b></td>
</tr>
<tr>
<td> Niger        </td>
<td> 77% (1998) </td>
<td> 56.6% (2011) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 7.8% (2008) </td>
</tr>
<tr>
<td> Chad        </td>
<td> 71% (1997) </td>
<td> 51.1% (2003) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 5.4% (2004) </td>
</tr>
<tr>
<td> Bangladesh        </td>
<td><i>65% (1999)</i></td>
<td><i>no data</i></td>
<td style='border-left: 2px solid black;padding-left: 2px'><i>no data</i></td>
</tr>
<tr>
<td> Guinea        </td>
<td> 65% (1999) </td>
<td> 70.5% (2010) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 22.3% (2009) </td>
</tr>
<tr>
<td> Mali        </td>
<td> 65% (2001) </td>
<td> 58.8% (2011) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 25.4% (2011) </td>
</tr>
<tr>
<td> Central African Republic        </td>
<td> 57% (1994) </td>
<td> 60.4% (2010) </td>
<td style='border-left: 2px solid black;padding-left: 2px'> 7.9% (2009) </td>
</tr>
<tr>
<td colspan='4' style='text-align: center;'> &#8230;        </td>
</tr>
</table>
<p>The relation is clear (secondary enrollment is also impacted by poverty and economic issues as well, but child marriage does make a difference); <b>being married as a child, dramatically decreases secondary school enrollment.</b></p>
<p>And, without a proper education, you likely can&#8217;t earn the money that you need to escape poverty, which you need to escape child marriage, which you need to escape child births, which you need to escape dropping out of school.</p>
<p><i>ad infinitum.</i></p>
<p>These numbers, abstract as they may be, show the magnitude of this problem. One that needs to be addressed, and now.<br />
<h3> How do we stop this vicious cycle?</h3>
<ul>
<li>The <b>law</b> is what we started this piece with, yet the figures that 10 million        girls become child brides every year &#8211; 71% of them from countries with a legal age        at or above 18 &#8211; and that countries like Armenia, Turkey, and Uzbekistan with legal        age less than 18 yet have drastically lower child marriage rates, show that the law        makes less of an impact than one would have thought (enforcement of the law is another        issue)</li>
<li>Increased availability of <b>contraceptives</b> gives women the power to plan their        own lives, it gives them the power of self-determination. With this, a woman can        decide when and how many children she would like to have, a power that will enable        her to space her children apart, improving both her own health (<a href='http://www.mayoclinic.com/health/family-planning/MY01691/'            target="_blank">Mayo Clinic</a>) and giving her the opportunity to care for        her own child, right when they need it the most. Religious hierarchies (like the        <a href='http://www.vatican.va/roman_curia/congregations/cfaith/documents/rc_con_cfaith_doc_20101221_luce-del-mondo_en.html'            target='_blank'>Catholic Church / Pope</a>) can make this difficult, but to        quote Melinda Gates, &#8216;let the women in Africa decide&#8217; (<a href='http://www.guardian.co.uk/world/2012/jul/11/melinda-gates-challenges-vatican-contraception' target='_blank'>Melinda            Gates</a> talking about contraceptives in Africa)</li>
<li><b>Education</b> empowers people, it allows them to take control of their life, and it can help take them out of poverty (<a href='http://www.ohchr.org/EN/Issues/Education/SREducation/Pages/SREducationIndex.aspx' target='_blank'>Office            of the High Commissioner for Human Rights</a>). Education can raise awareness        in communities about these issues (for example, can you imagine someone not being        aware that contraceptives exist? <a href='http://www.impatientoptimists.org/Posts/2012/06/Imagine-a-World-Without-Contraception'            target="_blank">Imagine a World&#8230; Without Contraception</a>, <a href='http://www.impatientoptimists.org/Posts/2012/07/Imagine-a-WorldWhere-You-Dont-Know-Contraception-Exists' target='_blank'> Imagine a World&#8230;Where You Don&#8217;t Know Contraception Exists</a>), and awareness        changes traditions (<a target='_blank' href='http://girlsnotbrides.org/child-marriage/'>Girls            not brides</a>). To quote Graça Machel, &#8216;traditions can change because they        are made by people&#8217;</li>
<li>By decreasing <b>poverty</b>, kids will be able to remain in school for longer and        avoid a child marriage (something that, sadly, is sometimes done because the family        cannot afford to take care of their daughter, <a href='http://www.icrw.org/files/images/Child-Marriage-Fact-Sheet-Poverty.pdf'            target="_blank">International Center for Reasearch on Women</a> &#8211; particularly        with the exchange of wealth during a marriage, present in South Asia and sub-Saharan        Africa).</li>
</ul>
<p>Child marriage, and its implications of an unfinished education, a worsened health, and the removal of one&#8217;s liberty, is an abuse of human rights, abusing those most vulnerable in our society. But, what can *we* do about it?<br />
<h3> How can *we* make a difference?</h3>
<ul>
<li>Learn more about the issue (MIT&#8217;s MOOC (Massive Online Open Course) <a id='rss' target='_blank' href="https://www.edx.org/courses/MITx/14.73x/2013_Spring/about">14.73x: The Challenges of Global Poverty</a> looks like a great introduction into the economic side of the issue), make up your own mind, and then spread the word</li>
<li>Petition your government to provide aid / support for the above steps (for a list        of countries that have pledged for providing contraceptives see <a href='http://www.londonfamilyplanningsummit.co.uk/1530%20CommitmentSummary_Final_.pdf'            target="_blank">London Summit on Family Planning pledges</a> &#8211; Australia is        one of them!)</li>
<li>&#8230;</li>
</ul>
<hr style='margin-top:70px'/>
<h4 style='margin-top:0px'>Notes:</h4>
<ul style='margin-top:-15px'>
<li>Data was sourced from <a target='_blank' href='http://data.un.org/'>UN Data</a> and the <a target='_blank' href='http://www.census.gov/population/international/data/idb/informationGateway.php'> US Census</a>. I also looked at <a target='_blank' href='http://data.worldbank.org/'> The World Bank Data</a> but didn&#8217;t up using that site.</li>
<li>You can download a copy of all the csv and Excel files that I used / edited <a id="rss" href='http://www.malteahrens.com/blog/wp-content/uploads/2012/07/The-Vicious-Cycle-data.zip' target='_blank'> here</a> (zip folder)</li>
<li>Besides using Excel (both VLookup / AverageIfs / SumIfs and scroll-select-copy-and-paste!), I used Python (3.2) to convert the csv files to the JavaScript array that Google Charts        wants. You can download the code <a id='rss' href='http://www.malteahrens.com/blog/wp-content/uploads/2012/07/The-Vicious-Cycle-code.py_.txt' target='_blank'>here</a></li>
<li>Take a look at <a href='http://www.gapminder.org/world/#$majorMode=chart$is;shi=t;ly=2003;lb=f;il=t;fs=11;al=30;stl=t;st=t;nsl=t;se=t$wst;tts=C$ts;sp=5.59290322580644;ti=2010$zpv;v=0$inc_x;mmid=XCOORDS;iid=phAwcNAVuyj1jiMAkmq1iMg;by=ind$inc_y;mmid=YCOORDS;iid=pyj6tScZqmEewsQOoKrtYJQ;by=ind$inc_s;uniValue=8.21;iid=phAwcNAVuyj0XOoBL_n5tAQ;by=ind$inc_c;uniValue=255;gid=CATID0;by=grp$map_x;scale=log;dataMin=194;dataMax=96846$map_y;scale=lin;sma=49;smi=2.65$cd;bd=0$inds=' target='_blank'> Gap Minder</a> for a fantastic way to visualize the change in data over time</li>
<li>If I have made any [statistical, legal, cultural, or otherwise] mistakes, please point them out, and then I can correct them</li>
<li>Besides my (still going&#8230;) high-school education which has empowered me to make this        informed research, I would like to thank Sebastian Thrun for his <a href='http://www.udacity.com/course/st101'            target='_blank'>Intro to Statistics</a> class on Udacity (which certainly helped!), and Rob Flavell (who also blogs on <a href='http://www.learnyougood.com/visualisation-for-deep-understanding'            target="_blank">data visualisation</a>)</li>
</ul>
<p><script type="text/javascript">
    function drawMaps() { drawMarriage(); drawLegalMeanMarriage(); drawLegalMeanMarriage_africa(); drawMarriageChild20to24(); drawContraceptives(); drawCPRvsUnmet(); drawSumContraceptives(); drawGeoPrimaryEducation(); drawGeoSecondaryEducation(); drawGeoAdolescentFertilityRate(); }
    function drawMarriage() { var table = new google.visualization.DataTable(); table.addColumn('string', 'Country'); table.addColumn('string', 'Source'); table.addColumn('number', 'Female age of consent'); table.addColumn('number', 'Male age of consent'); table.addRows([['Algeria', 'Algeria (UNDAW CEDAW Country Reports Aug2007)', 18, 21], ['Andorra', 'Andorra (UNDAW CEDAW Country Reports Aug2007)', 16, 16], ['Angola', 'Angola (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Antigua and Barbuda', 'Antigua and Barbuda (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Argentina', 'Argentina (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Armenia', 'Armenia (UNDAW CEDAW Country Reports Aug2007)', 17, 17], ['Australia', 'Australia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Austria', 'Austria (UNPD Inquiry on Population and Development 2003)', 16, 16], ['Azerbaijan', 'Azerbaijan (UNDAW CEDAW Country Reports Aug2007)', 17, 18], ['Bahamas', 'Bahamas (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Bangladesh', 'Bangladesh (UNDAW CEDAW Country Reports Aug2007)', 18, 21], ['Barbados', 'Barbados (UNDAW CEDAW Country Reports Aug2007)', 16, 16], ['Belarus', 'Belarus (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Belgium', 'Belgium (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Belize', 'Belize (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Benin', 'Benin (UNDAW CEDAW Country Reports Aug2007)', 15, 18], ['Bhutan', 'Bhutan (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Bolivia', 'Bolivia (UNDAW CEDAW Country Reports Aug2007)', 14, 16], ['Bosnia and Herzegovina', 'Bosnia and Herzegovina (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Botswana', 'Botswana (UNPD Inquiry on Population and Development 2003)', 21, 21], ['Brazil', 'Brazil (UNDAW CEDAW Country Reports Aug2007)', 21, 21], ['Bulgaria', 'Bulgaria (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Burkina Faso', 'Burkina Faso (UNDAW CEDAW Country Reports Aug2007)', 17, 20], ['Burundi', 'Burundi (UNDAW CEDAW Country Reports Aug2007)', 18, 21], ['Cambodia', 'Cambodia (UNDAW CEDAW Country Reports Aug2007)', 18, 20], ['Cameroon', 'Cameroon (UNDAW CEDAW Country Reports Aug2007)', 15, 18], ['Canada', 'Canada (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Cape Verde', 'Cape Verde (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Central African Republic', 'Central African Republic (UNPD Inquiry on Population and Development 2003)', 18, 22], ['Chile', 'Chile (UNPD Inquiry on Population and Development 2003)', 18, 18], ['China', 'China (UNPD Inquiry on Population and Development 2003)', 20, 22], ['Colombia', 'Colombia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Congo', 'Congo (UNDAW CEDAW Country Reports Aug2007)', 18, 21], ['Congo Dem. Rep.', 'Congo Dem. Rep. (UNDAW CEDAW Country Reports Aug2007)', 15, 18], ['Cook Islands', 'Cook Islands (UNDAW CEDAW Country Reports Aug2007)', 21, 21], ['Costa Rica', 'Costa Rica (UNDAW CEDAW Country Reports Aug2007)', 15, 15], ['Ivory Coast', 'Ivory Coast (UNPD Inquiry on Population and Development 2003)', 18, 21], ['Croatia', 'Croatia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Cuba', 'Cuba (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Cyprus', 'Cyprus (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Czech Republic', 'Czech Republic (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Denmark', 'Denmark (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Dominica', 'Dominica (UNPD Inquiry on Population and Development 2003)', 16, 16], ['Dominican Republic', 'Dominican Republic (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Ecuador', 'Ecuador (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Egypt', 'Egypt (UNPD Inquiry on Population and Development 2003)', 16, 18], ['El Salvador', 'El Salvador (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Equatorial Guinea', 'Equatorial Guinea (UNDAW CEDAW Country Reports Aug2007)', 12, 12], ['Eritrea', 'Eritrea (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Estonia', 'Estonia (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Ethiopia', 'Ethiopia (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Fiji', 'Fiji (UNPD Inquiry on Population and Development 2003)', 21, 21], ['Finland', 'Finland (UNPD Inquiry on Population and Development 2003)', 21, 21], ['France', 'France (UNPD Inquiry on Population and Development 2003)', 21, 21], ['Gabon', 'Gabon (UNDAW CEDAW Country Reports Aug2007)', 15, 18], ['Georgia', 'Georgia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Germany', 'Germany (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Ghana', 'Ghana (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Greece', 'Greece (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Guatemala', 'Guatemala (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Guinea', 'Guinea (UNDAW CEDAW Country Reports Aug2007)', 17, 18], ['Hungary', 'Hungary (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Iceland', 'Iceland (UNPD Inquiry on Population and Development 2003)', 18, 18], ['India', 'India (UNPD Inquiry on Population and Development 2003)', 18, 21], ['Indonesia', 'Indonesia (UNDAW CEDAW Country Reports Aug2007)', 16, 19], ['Iran', 'Iran (UNPD Inquiry on Population and Development 2003)', 15, -1], ['Iraq', 'Iraq (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Israel', 'Israel (UNPD Inquiry on Population and Development 2003)', 17, 17], ['Italy', 'Italy (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Jamaica', 'Jamaica (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Japan', 'Japan (UNPD Inquiry on Population and Development 2003)', 20, 20], ['Jordan', 'Jordan (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Kazakhstan', 'Kazakhstan (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Kenya', 'Kenya (UNPD Inquiry on Population and Development 2003)', 18, 18], ['North Korea', 'North Korea (UNDAW CEDAW Country Reports Aug2007)', 17, 18], ['South Korea', 'South Korea (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Kuwait', 'Kuwait (UNDAW CEDAW Country Reports Aug2007)', 15, 17], ['Kyrgyzstan', 'Kyrgyzstan (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Laos', 'Laos (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Latvia', 'Latvia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Liechtenstein', 'Liechtenstein (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Lithuania', 'Lithuania (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Luxembourg', 'Luxembourg (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Madagascar', 'Madagascar (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Malawi', 'Malawi (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Malaysia', 'Malaysia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Mali', 'Mali (UNDAW CEDAW Country Reports Aug2007)', 15, 18], ['Malta', 'Malta (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Mauritania', 'Mauritania (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Mauritius', 'Mauritius (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Mexico', 'Mexico (UNDAW CEDAW Country Reports Aug2007)', 14, 16], ['Mongolia', 'Mongolia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Morocco', 'Morocco (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Mozambique', 'Mozambique (UNDAW CEDAW Country Reports Aug2007)', 14, 16], ['Myanmar', 'Myanmar (UNPD Inquiry on Population and Development 2003)', 18, -1], ['Namibia', 'Namibia (UNPD Inquiry on Population and Development 2003)', 21, 21], ['Nepal', 'Nepal (UNPD Inquiry on Population and Development 2003)', 20, 20], ['Netherlands', 'Netherlands (UNPD Inquiry on Population and Development 2003)', 18, 18], ['New Zealand', 'New Zealand (UNPD Inquiry on Population and Development 2003)', 20, 20], ['Nicaragua', 'Nicaragua (UNDAW CEDAW Country Reports Aug2007)', 18, 21], ['Niger', 'Niger (UNDAW CEDAW Country Reports Aug2007)', 15, 18], ['Norway', 'Norway (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Oman', 'Oman (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Pakistan', 'Pakistan (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Panama', 'Panama (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Papua New Guinea', 'Papua New Guinea (UNPD Inquiry on Population and Development 2003)', 21, 21], ['Paraguay', 'Paraguay (UNDAW CEDAW Country Reports Aug2007)', 16, 16], ['Peru', 'Peru (UNDAW CEDAW Country Reports Aug2007)', 16, 16], ['Philippines', 'Philippines (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Poland', 'Poland (UNDAW CEDAW Country Reports Aug2007)', 18, 21], ['Portugal', 'Portugal (UNPD Inquiry on Population and Development 2003)', 16, 16], ['Republic of Moldova', 'Republic of Moldova (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Romania', 'Romania (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Russian Federation', 'Russian Federation (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Rwanda', 'Rwanda (UNPD Inquiry on Population and Development 2003)', 21, 21], ['Saint Lucia', 'Saint Lucia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Samoa', 'Samoa (UNDAW CEDAW Country Reports Aug2007)', 19, 21], ['San Marino', 'San Marino (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Saudi Arabia', 'Saudi Arabia (UNPD Inquiry on Population and Development 2003)', 17, 20], ['Serbia', 'Serbia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Sierra Leone', 'Sierra Leone (UNDAW CEDAW Country Reports Aug2007)', 21, 21], ['Singapore', 'Singapore (UNDAW CEDAW Country Reports Aug2007)', 21, 21], ['Slovakia', 'Slovakia (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Slovenia', 'Slovenia (UNPD Inquiry on Population and Development 2003)', 18, 18], ['South Africa', 'South Africa (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Spain', 'Spain (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Sri Lanka', 'Sri Lanka (UNDAW CEDAW Country Reports Aug2007)', 18, 18], ['Suriname', 'Suriname (UNPD Inquiry on Population and Development 2003)', 20, 20], ['Sweden', 'Sweden (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Switzerland', 'Switzerland (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Tanzania', 'Tanzania (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Thailand', 'Thailand (UNDAW CEDAW Country Reports Aug2007)', 17, 17], ['Togo', 'Togo (UNDAW CEDAW Country Reports Aug2007)', 17, 20], ['Trinidad and Tobago', 'Trinidad and Tobago (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Tunisia', 'Tunisia (UNPD Inquiry on Population and Development 2003)', 20, 20], ['Turkey', 'Turkey (UNDAW CEDAW Country Reports Aug2007)', 17, 17], ['Uganda', 'Uganda (UNPD Inquiry on Population and Development 2003)', 16, 18], ['Ukraine', 'Ukraine (UNPD Inquiry on Population and Development 2003)', 17, 18], ['United Kingdom', 'United Kingdom (UNPD Inquiry on Population and Development 2003)', 18, 18], ['United States of America', 'United States of America (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Uruguay', 'Uruguay (UNPD Inquiry on Population and Development 2003)', 18, 18], ['Uzbekistan', 'Uzbekistan (UNDAW CEDAW Country Reports Aug2007)', 17, 18], ['Vanuatu', 'Vanuatu (UNDAW CEDAW Country Reports Aug2007)', 16, 18], ['Venezuela', 'Venezuela (UNDAW CEDAW Country Reports Aug2007)', 14, 16], ['Vietnam', 'Vietnam (UNPD Inquiry on Population and Development 2003)', 18, 20], ['Yemen', 'Yemen (UNDAW CEDAW Country Reports Aug2007)', 15, 15], ['Zambia', 'Zambia (UNPD Inquiry on Population and Development 2003)', 21, 21]]); var options = { colorAxis: { colors: ['#FF3300', '#FF6600', '#FF9900', '#FFFFCC', '#FFFFCC', '#FFFFCC'] }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('marriage_chart')); chart.draw(table, options); }; function drawLegalMeanMarriage() {
        var data = new google.visualization.DataTable()
        data.addColumn('string', 'Legal Age'); data.addColumn('number', 'Min'); data.addColumn('number', 'Max'); data.addColumn('number', 'StdMin'); data.addColumn('number', 'StdMax'); data.addColumn({ type: 'string', role: 'tooltip' }); data.addColumn('number', 'Average age at marriage'); data.addColumn({ type: 'string', role: 'tooltip' }); data.addRows([['none', 19.6, 19.6, 21.8, 21.8, 'With a legal minimum age of 0 the mean age of marriage is 20.7', 18, 'Average age of 18'], ['14', 18, 19.41883872, 23.38116128, 22.8, 'With a legal minimum age of 14 the mean age of marriage is 21.4', 18, 'Average age of 18'], ['15', 17.6, 18.68257856, 22.89519922, 25.2, 'With a legal minimum age of 15 the mean age of marriage is 20.8', 18, 'Average age of 18'], ['16', 19.6, 20.8357331, 26.53760024, 31.8, 'With a legal minimum age of 16 the mean age of marriage is 23.7', 18, 'Average age of 18'], ['17', 18.7, 19.96911205, 23.72179704, 25, 'With a legal minimum age of 17 the mean age of marriage is 21.8', 18, 'Average age of 18'], ['18', 18.7, 20.93928886, 27.88471114, 33.7, 'With a legal minimum age of 18 the mean age of marriage is 24.4', 18, 'Average age of 18'], ['19', 23.9, 23.9, 23.9, 23.9, 'With a legal minimum age of 19 the mean age of marriage is 23.9', 18, 'Average age of 18'], ['20', 19, 21.24661269, 27.83338731, 28.6, 'With a legal minimum age of 20 the mean age of marriage is 24.5', 18, 'Average age of 18'], ['21', 19.8, 21.15633078, 28.09821468, 30.2, 'With a legal minimum age of 21 the mean age of marriage is 24.6', 18, 'Average age of 18'], ]); var options = { colors: ['#336699'], legend: 'none', vAxis: { minValue: 15, maxValue: 35, title: 'Average age at marriage' }, hAxis: { title: 'Legal minimum age' }, seriesType: "candlesticks", series: { 1: { type: "line", color: 'red'} }, backgroundColor: { fill: "none"} }; var chart = new google.visualization.ComboChart(document.getElementById('marriagecomp_chart')); chart.draw(data, options);
    }; function drawLegalMeanMarriage_africa() {
        var data = new google.visualization.DataTable()
        data.addColumn('string', 'Legal Age'); data.addColumn('number', 'Min'); data.addColumn('number', 'Max'); data.addColumn('number', 'StdMin'); data.addColumn('number', 'StdMax'); data.addColumn({ type: 'string', role: 'tooltip' }); data.addColumn('number', 'eighteen'); data.addColumn({ type: 'string', role: 'tooltip' }); data.addRows([['none', 19.6, 19.6, 19.6, 19.6, 'With a legal minimum age of none the mean age of marriage is 19.6', 18, 'Average age of 18'], ['14', 18, 18, 18, 18, 'With a legal minimum age of 14 the mean age of marriage is 18.0', 18, 'Average age of 18'], ['15', 17.6, 18.0823094, 21.1976906, 22.1, 'With a legal minimum age of 15 the mean age of marriage is 19.6', 18, 'Average age of 18'], ['16', 19.6, 19.6, 22.3, 22.3, 'With a legal minimum age of 16 the mean age of marriage is 20.9', 18, 'Average age of 18'], ['17', 18.7, 18.63785831, 22.56214169, 23.5, 'With a legal minimum age of 17 the mean age of marriage is 20.6', 18, 'Average age of 18'], ['18', 18.9, 19.8166983, 24.69441281, 27.9, 'With a legal minimum age of 18 the mean age of marriage is 22.3', 18, 'Average age of 18'], ['20', 26.6, 26.6, 26.6, 26.6, 'With a legal minimum age of 20 the mean age of marriage is 26.6', 18, 'Average age of 18'], ['21', 19.8, 20.55199717, 26.20800283, 26.9, 'With a legal minimum age of 21 the mean age of marriage is 23.4', 18, 'Average age of 18'], ]); var options = { colors: ['#006666'], legend: 'none', vAxis: { minValue: 15, maxValue: 35, title: 'Average age at marriage' }, hAxis: { title: 'Legal minimum age' }, seriesType: "candlesticks", series: { 1: { type: "line", color: 'red'} }, backgroundColor: { fill: "none"} }; var chart = new google.visualization.CandlestickChart(document.getElementById('merriagecomp_chart_africa')); chart.draw(data, options);
    }; function drawMarriageChild20to24() { var table = new google.visualization.DataTable(); table.addColumn('string', 'Country'); table.addColumn('string', 'Source'); table.addColumn('number', 'Married as children (percent)'); table.addColumn('number', 'Legal age of marriage'); table.addRows([['Armenia', 'Armenia - 2000', 19, 17], ['Bangladesh', 'Bangladesh - 1999/2000', 65, 18], ['Benin', 'Benin - 2001', 37, 15], ['Bolivia', 'Bolivia - 2003', 26, 14], ['Botswana', 'Botswana - 1988', 10, 21], ['Brazil', 'Brazil - 1996', 24, 21], ['Burkina Faso', 'Burkina Faso - 2003', 52, 17], ['Burundi', 'Burundi - 1987', 17, 18], ['Cambodia', 'Cambodia - 2000', 25, 18], ['Cameroon', 'Cameroon - 1998', 43, 15], ['Central African Republic', 'Central African Republic - 1994/1995', 57, 18], ['Chad', 'Chad - 1997', 71, -1], ['Colombia', 'Colombia - 2000', 21, 18], ['Comoros', 'Comoros - 1996', 30, -1], ['Cote d\'Ivoire', 'Cote d\'Ivoire - 1998/1999', 33, -1], ['Dominican Republic', 'Dominican Republic - 2002', 41, 18], ['Ecuador', 'Ecuador - 1987', 26, 18], ['Egypt', 'Egypt - 2003', 19, 16], ['Eritrea', 'Eritrea - 2002', 47, 18], ['Ethiopia', 'Ethiopia - 2000', 49, 18], ['Gabon', 'Gabon - 2000', 34, 15], ['Ghana', 'Ghana - 2003', 28, 18], ['Guatemala', 'Guatemala - 1999', 34, 18], ['Guinea', 'Guinea - 1999', 65, 17], ['Haiti', 'Haiti - 2000', 24, -1], ['India', 'India - 1999', 46, 18], ['Indonesia', 'Indonesia - 2002/2003', 24, 16], ['Jordan', 'Jordan - 2002', 11, 18], ['Kazakhstan', 'Kazakhstan - 1999', 14, 18], ['Kenya', 'Kenya - 2003', 25, 18], ['Kyrgyzstan', 'Kyrgyzstan - 1997', 21, 18], ['Liberia', 'Liberia - 1986', 48, -1], ['Madagascar', 'Madagascar - 2003/2004', 39, 18], ['Malawi', 'Malawi - 2000', 47, 18], ['Mali', 'Mali - 2001', 65, 15], ['Mauritania', 'Mauritania - 2000/2001', 37, 18], ['Mexico', 'Mexico - 1987', 28, 14], ['Morocco', 'Morocco - 2003/2004', 16, 18], ['Mozambique', 'Mozambique - 2003', 56, 14], ['Namibia', 'Namibia - 2000', 10, 21], ['Nepal', 'Nepal - 2001', 56, 20], ['Nicaragua', 'Nicaragua - 2000', 43, 18], ['Niger', 'Niger - 1998', 77, 15], ['Nigeria', 'Nigeria - 2003', 43, -1], ['Pakistan', 'Pakistan - 1990/1991', 32, 16], ['Paraguay', 'Paraguay - 1990', 24, 16], ['Peru', 'Peru - 2000', 19, 16], ['Philippines', 'Philippines - 2003', 14, 18], ['Rwanda', 'Rwanda - 2001', 20, 21], ['Senegal', 'Senegal - 1997', 36, -1], ['South Africa', 'South Africa - 1998', 8, 18], ['Sri Lanka', 'Sri Lanka - 1987', 14, 18], ['Sudan', 'Sudan - 1989/1990', 27, -1], ['Tanzania', 'Tanzania - 1999', 39, 18], ['Thailand', 'Thailand - 1987', 21, 17], ['Togo', 'Togo - 1998', 31, 17], ['Trinidad and Tobago', 'Trinidad and Tobago - 1987', 34, 18], ['Tunisia', 'Tunisia - 1988', 10, 20], ['Turkey', 'Turkey - 1998', 23, 17], ['Turkmenistan', 'Turkmenistan - 2001', 9, -1], ['Uganda', 'Uganda - 2000', 54, 16], ['Uzbekistan', 'Uzbekistan - 2002', 13, 17], ['Vietnam', 'Vietnam - 2002', 11, 18], ['Yemen', 'Yemen - 1997', 48, 15], ['Zambia', 'Zambia - 2002', 42, 21], ['Zimbabwe', 'Zimbabwe - 1999', 29, -1], ]); var options = { colorAxis: { colors: ['white', '#990000', '#660000', 'black'], minValue: 0, maxValue: 100 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('marriagechild20to24_chart')); chart.draw(table, options); }; function drawContraceptives() { var table = google.visualization.arrayToDataTable([['Country', 'Contraceptive prevalence rate (percentage)'], ['Afghanistan', 23], ['Albania', 69], ['Algeria', 61], ['Angola', 6], ['Argentina', 78], ['Armenia', 55], ['Australia', 71], ['Azerbaijan', 51], ['Bahamas', 45], ['Bangladesh', 53], ['Belarus', 73], ['Belgium', 75], ['Belize', 34], ['Benin', 17], ['Bhutan', 66], ['Bolivia', 61], ['Bosnia and Herzegovina', 36], ['Botswana', 53], ['Brazil', 81], ['Burkina Faso', 17], ['Burundi', 22], ['Cambodia', 51], ['Cameroon', 29], ['Canada', 74], ['Cape Verde', 61], ['Central African Republic', 19], ['Chad', 5], ['Chile', 58], ['China', 85], ['Colombia', 79], ['Comoros', 26], ['Congo', 44], ['Cook Islands', 44], ['Costa Rica', 80], ['Ivory Coast', 13], ['Cuba', 78], ['North Korea', 69], ['Democratic Republic of the Congo', 17], ['Djibouti', 23], ['Dominican Republic', 73], ['East Asia and Pacific', 78], ['Eastern and Southern Africa', 36], ['Ecuador', 73], ['Egypt', 60], ['El Salvador', 73], ['Eritrea', 8], ['Ethiopia', 15], ['Fiji', 35], ['France', 71], ['Gabon', 33], ['Gambia', 18], ['Georgia', 53], ['Ghana', 24], ['Greece', 76], ['Grenada', 54], ['Guatemala', 54], ['Guinea', 9], ['Guinea-Bissau', 14], ['Guyana', 43], ['Haiti', 32], ['Honduras', 65], ['India', 54], ['Indonesia', 61], ['Iran', 79], ['Iraq', 50], ['Ireland', 89], ['Jamaica', 69], ['Japan', 54], ['Jordan', 59], ['Kazakhstan', 51], ['Kenya', 46], ['Kiribati', 22], ['Kyrgyzstan', 48], ['Laos', 38], ['Lebanon', 58], ['Lesotho', 47], ['Liberia', 11], ['Madagascar', 40], ['Malawi', 41], ['Maldives', 35], ['Mali', 8], ['Marshall Islands', 45], ['Mauritania', 9], ['Mauritius', 76], ['Mexico', 73], ['Mongolia', 55], ['Montenegro', 39], ['Morocco', 63], ['Mozambique', 16], ['Myanmar', 41], ['Namibia', 55], ['Nauru', 36], ['Nepal', 48], ['Netherlands', 69], ['Nicaragua', 72], ['Niger', 18], ['Nigeria', 15], ['Niue', 23], ['Norway', 88], ['Occupied Palestinian Territory', 50], ['Oman', 24], ['Pakistan', 27], ['Palau', 21], ['Panama', 52], ['Papua New Guinea', 32], ['Paraguay', 79], ['Peru', 74], ['Philippines', 51], ['Portugal', 67], ['South Korea', 80], ['Moldova', 68], ['Romania', 70], ['Russian Federation', 80], ['Rwanda', 52], ['Saint Kitts and Nevis', 54], ['Saint Vincent and the Grenadines', 48], ['Samoa', 29], ['Sao Tome and Principe', 38], ['Saudi Arabia', 24], ['Senegal', 12], ['Serbia', 41], ['Sierra Leone', 8], ['Solomon Islands', 35], ['Somalia', 15], ['South Africa', 60], ['South Asia', 51], ['South Sudan', 8], ['Spain', 66], ['Sri Lanka', 68], ['Sudan', 8], ['Suriname', 46], ['Swaziland', 49], ['Syrian Arab Republic', 54], ['Tajikistan', 37], ['Thailand', 80], ['Macedonia', 14], ['Timor-Leste', 22], ['Togo', 15], ['Tonga', 23], ['Trinidad and Tobago', 43], ['Tunisia', 60], ['Turkey', 73], ['Turkmenistan', 48], ['Tuvalu', 31], ['Uganda', 24], ['Ukraine', 67], ['United Kingdom', 84], ['Tanzania', 34], ['United States', 79], ['Uruguay', 78], ['Uzbekistan', 65], ['Vanuatu', 38], ['Viet Nam', 80], ['Yemen', 28], ['Zambia', 41], ['Zimbabwe', 59], ]); var options = { colorAxis: { colors: ['black', 'blue', 'white'], minValue: 0, maxValue: 100 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('contraceptives_chart')); chart.draw(table, options); }
    function drawCPRvsUnmet() {
        var data = new google.visualization.DataTable()
        data.addColumn('string', 'Country'); data.addColumn('string', 'Source'); data.addColumn('number', 'Unmet needs (percentage)'); data.addRows([['Albania', 'Albania (2008)', 12.8], ['Armenia', 'Armenia (2005)', 13.3], ['Azerbaijan', 'Azerbaijan (2006)', 15.1], ['Bangladesh', 'Bangladesh (2007)', 16.8], ['Belgium', 'Belgium (1992)', 3.4], ['Belize', 'Belize (1999)', 20.8], ['Benin', 'Benin (2006)', 26.4], ['Bolivia', 'Bolivia (2008)', 20.2], ['Brazil', 'Brazil (2006)', 6], ['Burkina Faso', 'Burkina Faso (2003)', 28.8], ['Burundi', 'Burundi (2002)', 29], ['Cambodia', 'Cambodia (2005)', 25.1], ['Cameroon', 'Cameroon (2004)', 20.2], ['Cape Verde', 'Cape Verde (2005)', 16.7], ['Central African Republic', 'Central African Republic (1995)', 16.2], ['Chad', 'Chad (2004)', 19.1], ['China', 'China (2001)', 2.3], ['Colombia', 'Colombia (2005)', 5.7], ['Comoros', 'Comoros (1996)', 34.6], ['Congo', 'Congo (2005)', 19.3], ['Costa Rica', 'Costa Rica (1993)', 5], ['Cote d\'Ivoire', 'Cote d\'Ivoire (1999)', 27.7], ['Democratic Republic of the Congo', 'Democratic Republic of the Congo (2007)', 26.2], ['Dominican Republic', 'Dominican Republic (2007)', 11.4], ['Ecuador', 'Ecuador (2004)', 7.4], ['Egypt', 'Egypt (2008)', 9.2], ['El Salvador', 'El Salvador (2003)', 8.9], ['Eritrea', 'Eritrea (2002)', 27], ['Ethiopia', 'Ethiopia (2005)', 33.8], ['France', 'France (2005)', 1.7], ['Gabon', 'Gabon (2000)', 28], ['Georgia', 'Georgia (2005)', 16.3], ['Ghana', 'Ghana (2008)', 35.3], ['Guatemala', 'Guatemala (2002)', 27.6], ['Guinea', 'Guinea (2005)', 21.2], ['Haiti', 'Haiti (2006)', 37.5], ['Honduras', 'Honduras (2006)', 16.9], ['India', 'India (2006)', 12.6], ['Indonesia', 'Indonesia (2007)', 8.8], ['Jamaica', 'Jamaica (2003)', 11.7], ['Jordan', 'Jordan (2009)', 11.2], ['Kazakhstan', 'Kazakhstan (1999)', 8.7], ['Kenya', 'Kenya (2009)', 25.6], ['Kyrgyzstan', 'Kyrgyzstan (1997)', 11.6], ['Laos', 'Laos (2005)', 27], ['Lesotho', 'Lesotho (2010)', 23], ['Liberia', 'Liberia (2007)', 35.6], ['Madagascar', 'Madagascar (2009)', 18.9], ['Malawi', 'Malawi (2004)', 27.6], ['Maldives', 'Maldives (2009)', 28.1], ['Mali', 'Mali (2006)', 26.7], ['Marshall Islands', 'Marshall Islands (2007)', 8.1], ['Mauritania', 'Mauritania (2001)', 31.6], ['Mauritius', 'Mauritius (2002)', 3.5], ['Mexico', 'Mexico (2006)', 12], ['Mongolia', 'Mongolia (2003)', 4.6], ['Morocco', 'Morocco (2004)', 10], ['Mozambique', 'Mozambique (2004)', 18.4], ['Myanmar', 'Myanmar (2001)', 19.1], ['Namibia', 'Namibia (2007)', 20.6], ['Nepal', 'Nepal (2006)', 24.6], ['Nicaragua', 'Nicaragua (2007)', 7.5], ['Niger', 'Niger (2006)', 15.7], ['Nigeria', 'Nigeria (2008)', 20.2], ['Pakistan', 'Pakistan (2007)', 24.9], ['Paraguay', 'Paraguay (2008)', 4.7], ['Peru', 'Peru (2009)', 7.2], ['Philippines', 'Philippines (2008)', 22.3], ['Moldova', 'Moldova (2005)', 6.7], ['Romania', 'Romania (2004)', 11.9], ['Rwanda', 'Rwanda (2005)', 37.9], ['Samoa', 'Samoa (2009)', 45.6], ['Sao Tome and Principe', 'Sao Tome and Principe (2009)', 37.2], ['Senegal', 'Senegal (2005)', 31.6], ['Sierra Leone', 'Sierra Leone (2008)', 27.6], ['Solomon Islands', 'Solomon Islands (2007)', 11.1], ['South Africa', 'South Africa (2004)', 13.8], ['Spain', 'Spain (1995)', 11.8], ['Sri Lanka', 'Sri Lanka (2007)', 7.3], ['Sudan', 'Sudan (1993)', 26], ['Swaziland', 'Swaziland (2007)', 23.8], ['Thailand', 'Thailand (2006)', 3.1], ['Timor-Leste', 'Timor-Leste (2010)', 30.8], ['Togo', 'Togo (1998)', 32.3], ['Tunisia', 'Tunisia (2001)', 12.1], ['Turkey', 'Turkey (2008)', 6.2], ['Turkmenistan', 'Turkmenistan (2000)', 10.1], ['Tuvalu', 'Tuvalu (2007)', 24.2], ['Uganda', 'Uganda (2006)', 37.8], ['Ukraine', 'Ukraine (2007)', 10.3], ['Tanzania', 'Tanzania (2005)', 21.8], ['United States', 'United States (2008)', 6.6], ['Uzbekistan', 'Uzbekistan (1996)', 13.7], ['Viet Nam', 'Viet Nam (2002)', 4.8], ['Yemen', 'Yemen (1997)', 38.6], ['Zambia', 'Zambia (2007)', 26.5], ['Zimbabwe', 'Zimbabwe (2006)', 12], ]); var options = { colorAxis: { colors: ['white', '#FF0000', 'black'], minValue: 0, maxValue: 100 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('unmetcontraceptives_chart')); chart.draw(data, options);
    }
    function drawSumContraceptives() {
        var data = new google.visualization.DataTable()
        data.addColumn('string', 'Country'); data.addColumn('string', 'Source'); data.addColumn('number', 'Proportion using, or wanting to use, contraceptives (percentage)'); data.addRows([['Albania', 'Albania (2008)', 81.8], ['Armenia', 'Armenia (2005)', 68.3], ['Azerbaijan', 'Azerbaijan (2006)', 66.1], ['Bangladesh', 'Bangladesh (2007)', 69.8], ['Belgium', 'Belgium (1992)', 78.4], ['Belize', 'Belize (1999)', 54.8], ['Benin', 'Benin (2006)', 43.4], ['Bolivia', 'Bolivia (2008)', 81.2], ['Brazil', 'Brazil (2006)', 87], ['Burkina Faso', 'Burkina Faso (2003)', 45.8], ['Burundi', 'Burundi (2002)', 51], ['Cambodia', 'Cambodia (2005)', 76.1], ['Cameroon', 'Cameroon (2004)', 49.2], ['Cape Verde', 'Cape Verde (2005)', 77.7], ['Central African Republic', 'Central African Republic (1995)', 35.2], ['Chad', 'Chad (2004)', 24.1], ['China', 'China (2001)', 87.3], ['Colombia', 'Colombia (2005)', 84.7], ['Comoros', 'Comoros (1996)', 60.6], ['Congo', 'Congo (2005)', 63.3], ['Costa Rica', 'Costa Rica (1993)', 85], ['Cote d\'Ivoire', 'Cote d\'Ivoire (1999)', 40.7], ['Democratic Republic of the Congo', 'Democratic Republic of the Congo (2007)', 43.2], ['Dominican Republic', 'Dominican Republic (2007)', 84.4], ['Ecuador', 'Ecuador (2004)', 80.4], ['Egypt', 'Egypt (2008)', 69.2], ['El Salvador', 'El Salvador (2003)', 81.9], ['Eritrea', 'Eritrea (2002)', 35], ['Ethiopia', 'Ethiopia (2005)', 48.8], ['France', 'France (2005)', 72.7], ['Gabon', 'Gabon (2000)', 61], ['Georgia', 'Georgia (2005)', 69.3], ['Ghana', 'Ghana (2008)', 59.3], ['Guatemala', 'Guatemala (2002)', 81.6], ['Guinea', 'Guinea (2005)', 30.2], ['Haiti', 'Haiti (2006)', 69.5], ['Honduras', 'Honduras (2006)', 81.9], ['India', 'India (2006)', 66.6], ['Indonesia', 'Indonesia (2007)', 69.8], ['Jamaica', 'Jamaica (2003)', 80.7], ['Jordan', 'Jordan (2009)', 70.2], ['Kazakhstan', 'Kazakhstan (1999)', 59.7], ['Kenya', 'Kenya (2009)', 71.6], ['Kyrgyzstan', 'Kyrgyzstan (1997)', 59.6], ['Laos', 'Laos (2005)', 65], ['Lesotho', 'Lesotho (2010)', 70], ['Liberia', 'Liberia (2007)', 46.6], ['Madagascar', 'Madagascar (2009)', 58.9], ['Malawi', 'Malawi (2004)', 68.6], ['Maldives', 'Maldives (2009)', 63.1], ['Mali', 'Mali (2006)', 34.7], ['Marshall Islands', 'Marshall Islands (2007)', 53.1], ['Mauritania', 'Mauritania (2001)', 40.6], ['Mauritius', 'Mauritius (2002)', 79.5], ['Mexico', 'Mexico (2006)', 85], ['Mongolia', 'Mongolia (2003)', 59.6], ['Morocco', 'Morocco (2004)', 73], ['Mozambique', 'Mozambique (2004)', 34.4], ['Myanmar', 'Myanmar (2001)', 60.1], ['Namibia', 'Namibia (2007)', 75.6], ['Nepal', 'Nepal (2006)', 72.6], ['Nicaragua', 'Nicaragua (2007)', 79.5], ['Niger', 'Niger (2006)', 33.7], ['Nigeria', 'Nigeria (2008)', 35.2], ['Pakistan', 'Pakistan (2007)', 51.9], ['Paraguay', 'Paraguay (2008)', 83.7], ['Peru', 'Peru (2009)', 81.2], ['Philippines', 'Philippines (2008)', 73.3], ['Moldova', 'Moldova (2005)', 74.7], ['Romania', 'Romania (2004)', 81.9], ['Rwanda', 'Rwanda (2005)', 89.9], ['Samoa', 'Samoa (2009)', 74.6], ['Sao Tome and Principe', 'Sao Tome and Principe (2009)', 75.2], ['Senegal', 'Senegal (2005)', 43.6], ['Sierra Leone', 'Sierra Leone (2008)', 35.6], ['Solomon Islands', 'Solomon Islands (2007)', 46.1], ['South Africa', 'South Africa (2004)', 73.8], ['Spain', 'Spain (1995)', 77.8], ['Sri Lanka', 'Sri Lanka (2007)', 75.3], ['Sudan', 'Sudan (1993)', 34], ['Swaziland', 'Swaziland (2007)', 72.8], ['Thailand', 'Thailand (2006)', 83.1], ['Timor-Leste', 'Timor-Leste (2010)', 52.8], ['Togo', 'Togo (1998)', 47.3], ['Tunisia', 'Tunisia (2001)', 72.1], ['Turkey', 'Turkey (2008)', 79.2], ['Turkmenistan', 'Turkmenistan (2000)', 58.1], ['Tuvalu', 'Tuvalu (2007)', 55.2], ['Uganda', 'Uganda (2006)', 61.8], ['Ukraine', 'Ukraine (2007)', 77.3], ['Tanzania', 'Tanzania (2005)', 55.8], ['United States', 'United States (2008)', 85.6], ['Uzbekistan', 'Uzbekistan (1996)', 78.7], ['Viet Nam', 'Viet Nam (2002)', 84.8], ['Yemen', 'Yemen (1997)', 66.6], ['Zambia', 'Zambia (2007)', 67.5], ['Zimbabwe', 'Zimbabwe (2006)', 71], ]); var options = { colorAxis: { colors: ['black', 'green', 'white'], minValue: 0, maxValue: 100 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('sumcontraceptives_chart')); chart.draw(data, options);
    }
    function drawGeoPrimaryEducation() { var table = new google.visualization.DataTable(); table.addColumn('string', 'Country'); table.addColumn('string', 'Label'); table.addColumn('number', 'Girls enrollment rate'); table.addColumn('number', 'Boys enrollment rate'); table.addRows([['Albania', 'Albania - 2010', 80.1, 79.7], ['Algeria', 'Algeria - 2010', 94.6, 96.6], ['Andorra', 'Andorra - 2010', 77.54, 76.7], ['Angola', 'Angola - 2010', 78.21, 93.06], ['Anguilla', 'Anguilla - 2008', 92.76, 92.73], ['Antigua and Barbuda', 'Antigua and Barbuda - 2010', 84.01, 89.37], ['Argentina', 'Argentina - 2005', 99.02, 99.85], ['Armenia', 'Armenia - 2007', 88.5, 85.8], ['Aruba', 'Aruba - 2010', 99.88, 99.51], ['Australia', 'Australia - 2009', 97.37, 96.76], ['Austria', 'Austria - 1999', 90.6, 89.64], ['Azerbaijan', 'Azerbaijan - 2010', 83.85, 84.97], ['Bahamas', 'Bahamas - 2010', 99.67, 94.25], ['Bahrain', 'Bahrain - 2006', 98.04, 97.66], ['Barbados', 'Barbados - 2008', 97.45, 89.76], ['Belarus', 'Belarus - 2010', 88.65, 90.36], ['Belgium', 'Belgium - 2009', 98.96, 98.71], ['Belize', 'Belize - 2010', 88.05, 97.58], ['Benin', 'Benin - 2010', 81.49, 96.8], ['Bermuda', 'Bermuda - 2010', 82.53, 82.98], ['Bhutan', 'Bhutan - 2011', 89.6, 87.0], ['Bolivia', 'Bolivia - 2007', 94.5, 93.88], ['Bosnia and Herzegovina', 'Bosnia and Herzegovina - 2010', 86.08, 84.29], ['Botswana', 'Botswana - 2007', 86.41, 84.8], ['Brazil', 'Brazil - 2008', 93.11, 95.12], ['British Virgin Islands', 'British Virgin Islands - 2010', 85.17, 88.41], ['Bulgaria', 'Bulgaria - 2009', 98.04, 97.43], ['Burkina Faso', 'Burkina Faso - 2011', 61.09, 65.19], ['Burundi', 'Burundi - 2007', 88.71, 90.77], ['Cambodia', 'Cambodia - 2010', 95.4, 96.44], ['Cameroon', 'Cameroon - 2010', 85.93, 98.74], ['Canada', 'Canada - 2000', 99.92, 99.6], ['Cape Verde', 'Cape Verde - 2010', 92.07, 94.3], ['Cayman Islands', 'Cayman Islands - 2008', 81.19, 81.89], ['Central African Republic', 'Central African Republic - 2010', 60.4, 80.82], ['Chad', 'Chad - 2003', 51.13, 73.37], ['Chile', 'Chile - 2009', 93.45, 93.69], ['Colombia', 'Colombia - 2010', 87.53, 88.6], ['Comoros', 'Comoros - 2007', 74.78, 80.65], ['Congo', 'Congo - 2010', 89.32, 92.32], ['Cook Islands', 'Cook Islands - 2010', 94.56, 94.21], ['Cote d\'Ivoire', 'Cote d\'Ivoire - 2009', 55.82, 67.11], ['Croatia', 'Croatia - 2009', 87.32, 87.64], ['Cuba', 'Cuba - 2010', 99.07, 99.36], ['Cyprus', 'Cyprus - 2009', 98.45, 99.03], ['Czech Republic', 'Czech Republic - 1999', 96.04, 95.84], ['Democratic Republic of the Congo', 'Democratic Republic of the Congo - 1999', 32.23, 33.9], ['Denmark', 'Denmark - 2009', 96.57, 94.56], ['Djibouti', 'Djibouti - 2009', 42.14, 46.79], ['Dominica', 'Dominica - 2009', 94.67, 93.54], ['Dominican Republic', 'Dominican Republic - 2010', 86.97, 93.28], ['Ecuador', 'Ecuador - 2009', 98.41, 95.74], ['Egypt', 'Egypt - 2009', 94.14, 97.38], ['El Salvador', 'El Salvador - 2010', 93.67, 93.8], ['Equatorial Guinea', 'Equatorial Guinea - 2010', 56.02, 56.54], ['Eritrea', 'Eritrea - 2010', 31.03, 35.84], ['Estonia', 'Estonia - 2009', 93.27, 94.59], ['Ethiopia', 'Ethiopia - 2010', 78.63, 83.89], ['Fiji', 'Fiji - 2009', 96.67, 96.67], ['Finland', 'Finland - 2009', 97.55, 97.41], ['France', 'France - 2009', 98.64, 98.42], ['Gambia', 'Gambia - 2010', 66.61, 64.42], ['Georgia', 'Georgia - 2009', 93.47, 95.43], ['Germany', 'Germany - 2009', 97.14, 97.51], ['Ghana', 'Ghana - 2011', 84.38, 83.56], ['Greece', 'Greece - 2007', 98.54, 98.05], ['Grenada', 'Grenada - 2009', 86.67, 87.37], ['Guatemala', 'Guatemala - 2010', 95.82, 97.96], ['Guinea', 'Guinea - 2010', 70.46, 83.23], ['Guinea-Bissau', 'Guinea-Bissau - 2010', 72.36, 75.46], ['Guyana', 'Guyana - 2010', 82.19, 79.09], ['Holy See', 'Holy See - 2011', 0.0, 0.0], ['Honduras', 'Honduras - 2010', 97.28, 95.06], ['Hong Kong', 'Hong Kong - 2010', 95.08, 92.59], ['Hungary', 'Hungary - 2009', 91.71, 92.99], ['Iceland', 'Iceland - 2009', 99.43, 99.29], ['India', 'India - 2008', 88.51, 91.96], ['Indonesia', 'Indonesia - 2010', 96.87, 95.16], ['Iran', 'Iran - 2007', 99.9, 99.05], ['Iraq', 'Iraq - 2007', 83.66, 94.49], ['Ireland', 'Ireland - 2009', 95.15, 95.05], ['Israel', 'Israel - 2009', 97.24, 96.59], ['Italy', 'Italy - 2009', 97.47, 98.2], ['Jamaica', 'Jamaica - 2010', 80.99, 83.09], ['Jordan', 'Jordan - 2008', 90.57, 88.81], ['Kazakhstan', 'Kazakhstan - 2011', 87.69, 88.72], ['Kenya', 'Kenya - 2009', 83.25, 82.32], ['Kiribati', 'Kiribati - 2002', 97.44, 96.7], ['Kuwait', 'Kuwait - 2008', 93.54, 90.78], ['Kyrgyzstan', 'Kyrgyzstan - 2010', 86.81, 88.08], ['Laos', 'Laos - 2008', 87.04, 90.85], ['Latvia', 'Latvia - 2010', 95.82, 94.37], ['Lebanon', 'Lebanon - 2010', 91.2, 92.16], ['Lesotho', 'Lesotho - 2010', 74.75, 71.98], ['Liberia', 'Liberia - 1999', 40.17, 51.75], ['Liechtenstein', 'Liechtenstein - 2009', 92.13, 91.59], ['Lithuania', 'Lithuania - 2009', 92.72, 93.94], ['Luxembourg', 'Luxembourg - 2008', 95.87, 94.22], ['Macao', 'Macao - 2010', 84.15, 80.9], ['Madagascar', 'Madagascar - 2003', 79.32, 79.01], ['Malawi', 'Malawi - 2009', 99.4, 94.44], ['Malaysia', 'Malaysia - 2005', 95.92, 95.86], ['Maldives', 'Maldives - 2011', 96.12, 96.24], ['Mali', 'Mali - 2011', 58.77, 66.92], ['Malta', 'Malta - 2009', 89.27, 88.5], ['Marshall Islands', 'Marshall Islands - 2011', 94.89, 96.69], ['Mauritania', 'Mauritania - 2010', 75.67, 72.45], ['Mauritius', 'Mauritius - 2010', 94.45, 92.39], ['Mexico', 'Mexico - 2009', 98.16, 97.94], ['Moldova', 'Moldova - 2010', 87.4, 87.77], ['Mongolia', 'Mongolia - 2009', 87.98, 89.75], ['Montserrat', 'Montserrat - 2007', 96.07, 89.05], ['Morocco', 'Morocco - 2011', 95.12, 96.32], ['Mozambique', 'Mozambique - 2010', 89.22, 94.48], ['Namibia', 'Namibia - 2009', 87.62, 83.22], ['Nepal', 'Nepal - 2000', 63.96, 77.87], ['Netherlands', 'Netherlands - 2009', 99.34, 99.78], ['New Zealand', 'New Zealand - 2010', 99.48, 99.15], ['Nicaragua', 'Nicaragua - 2010', 92.94, 92.04], ['Niger', 'Niger - 2011', 56.61, 68.04], ['Nigeria', 'Nigeria - 2007', 59.34, 64.78], ['Niue', 'Niue - 1999', 98.41, 98.63], ['Norway', 'Norway - 2009', 99.15, 98.82], ['Occupied Palestinian Territory', 'Occupied Palestinian Territory - 2010', 85.63, 87.41], ['Oman', 'Oman - 2009', 92.33, 94.88], ['Pakistan', 'Pakistan - 2010', 66.51, 81.3], ['Palau', 'Palau - 2000', 94.47, 98.3], ['Panama', 'Panama - 2010', 97.49, 98.53], ['Paraguay', 'Paraguay - 2009', 85.0, 85.16], ['Peru', 'Peru - 2009', 94.68, 94.36], ['Philippines', 'Philippines - 2009', 89.03, 87.56], ['Poland', 'Poland - 2009', 95.74, 96.02], ['Portugal', 'Portugal - 2009', 99.3, 99.06], ['Puerto Rico', 'Puerto Rico - 2010', 88.09, 83.2], ['Qatar', 'Qatar - 2010', 92.32, 91.63], ['South Korea', 'South Korea - 2009', 98.83, 99.71], ['Romania', 'Romania - 2009', 87.01, 87.4], ['Russian Federation', 'Russian Federation - 2009', 93.25, 93.48], ['Rwanda', 'Rwanda - 2010', 92.2, 88.96], ['Saint Kitts and Nevis', 'Saint Kitts and Nevis - 2010', 83.26, 83.09], ['Saint Lucia', 'Saint Lucia - 2010', 87.29, 89.01], ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines - 2010', 91.31, 96.48], ['Samoa', 'Samoa - 2010', 98.45, 94.74], ['San Marino', 'San Marino - 2009', 92.97, 91.12], ['Sao Tome and Principe', 'Sao Tome and Principe - 2010', 99.69, 97.11], ['Saudi Arabia', 'Saudi Arabia - 2009', 89.35, 90.38], ['Senegal', 'Senegal - 2010', 77.73, 73.31], ['Serbia', 'Serbia - 2010', 92.49, 92.99], ['Seychelles', 'Seychelles - 2005', 93.99, 96.24], ['Slovenia', 'Slovenia - 2009', 96.57, 96.95], ['Solomon Islands', 'Solomon Islands - 2007', 81.06, 82.85], ['South Africa', 'South Africa - 2009', 84.93, 85.27], ['Spain', 'Spain - 2009', 99.82, 99.81], ['Sri Lanka', 'Sri Lanka - 2010', 94.32, 93.75], ['Suriname', 'Suriname - 2009', 90.96, 90.87], ['Swaziland', 'Swaziland - 2010', 85.0, 86.09], ['Sweden', 'Sweden - 2009', 98.99, 99.63], ['Switzerland', 'Switzerland - 2009', 93.51, 93.7], ['Syria', 'Syria - 2010', 92.77, 94.18], ['Tajikistan', 'Tajikistan - 2010', 95.47, 99.02], ['Thailand', 'Thailand - 2009', 89.37, 89.97], ['Macedonia', 'Macedonia - 2009', 87.52, 86.4], ['Timor-Leste', 'Timor-Leste - 2010', 84.9, 85.74], ['Togo', 'Togo - 2008', 86.52, 97.18], ['Tonga', 'Tonga - 2006', 93.28, 97.47], ['Trinidad and Tobago', 'Trinidad and Tobago - 2010', 93.12, 93.98], ['Tunisia', 'Tunisia - 2009', 97.8, 99.13], ['Turkey', 'Turkey - 2009', 96.73, 98.22], ['Turks and Caicos Islands', 'Turks and Caicos Islands - 2005', 80.69, 75.2], ['Uganda', 'Uganda - 2010', 92.14, 89.62], ['Ukraine', 'Ukraine - 2010', 91.1, 90.4], ['United Arab Emirates', 'United Arab Emirates - 2006', 90.13, 86.78], ['United Kingdom', 'United Kingdom - 2009', 99.54, 99.69], ['Tanzania', 'Tanzania - 2008', 97.72, 98.26], ['United States of America', 'United States of America - 2010', 94.76, 94.36], ['Uruguay', 'Uruguay - 2009', 98.79, 99.49], ['Uzbekistan', 'Uzbekistan - 2011', 88.35, 91.19], ['Vanuatu', 'Vanuatu - 2005', 97.43, 99.84], ['Venezuela', 'Venezuela - 2010', 92.48, 92.57], ['Yemen', 'Yemen - 2010', 70.02, 84.81], ['Zambia', 'Zambia - 2010', 92.48, 90.27], ]); var options = { colorAxis: { colors: ['black', 'purple', 'white'], minValue: 0, maxValue: 100 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('primaryeducationgeo_chart')); chart.draw(table, options); }; function drawGeoSecondaryEducation() { var table = new google.visualization.DataTable(); table.addColumn('string', 'Country'); table.addColumn('string', 'Label'); table.addColumn('number', 'Girls enrollment rate'); table.addColumn('number', 'Boys enrollment rate'); table.addRows([['Afghanistan', 'Afghanistan - 2007', 13.08, 34.3], ['Albania', 'Albania - 2003', 73.31, 75.23], ['Algeria', 'Algeria - 2004', 68.5, 64.9], ['Andorra', 'Andorra - 2010', 74.64, 74.15], ['Angola', 'Angola - 2009', 10.86, 12.17], ['Anguilla', 'Anguilla - 2005', 79.07, 82.58], ['Antigua and Barbuda', 'Antigua and Barbuda - 2010', 84.58, 85.29], ['Argentina', 'Argentina - 2009', 86.58, 77.93], ['Armenia', 'Armenia - 2010', 87.68, 85.0], ['Aruba', 'Aruba - 2009', 74.62, 71.63], ['Australia', 'Australia - 2009', 86.08, 84.46], ['Azerbaijan', 'Azerbaijan - 2006', 77.91, 80.66], ['Bahamas', 'Bahamas - 2010', 88.45, 82.3], ['Bahrain', 'Bahrain - 2006', 96.96, 91.72], ['Barbados', 'Barbados - 2010', 87.65, 80.81], ['Belarus', 'Belarus - 2010', 88.88, 86.97], ['Belgium', 'Belgium - 2005', 86.53, 89.76], ['Belize', 'Belize - 2003', 65.49, 64.49], ['Benin', 'Benin - 2001', 12.77, 27.34], ['Bermuda', 'Bermuda - 2010', 51.28, 48.16], ['Bhutan', 'Bhutan - 2011', 57.24, 50.39], ['Bolivia', 'Bolivia - 2009', 68.7, 67.52], ['Botswana', 'Botswana - 2007', 63.0, 54.64], ['British Virgin Islands', 'British Virgin Islands - 2007', 88.71, 78.86], ['Brunei Darussalam', 'Brunei Darussalam - 2009', 99.39, 95.49], ['Bulgaria', 'Bulgaria - 2009', 81.59, 83.87], ['Burkina Faso', 'Burkina Faso - 2011', 15.53, 19.41], ['Burundi', 'Burundi - 2010', 14.57, 17.74], ['Cambodia', 'Cambodia - 2007', 32.76, 37.37], ['Cape Verde', 'Cape Verde - 2010', 70.84, 61.06], ['Cayman Islands', 'Cayman Islands - 2008', 78.49, 74.31], ['Central African Republic', 'Central African Republic - 2009', 7.87, 13.49], ['Chad', 'Chad - 2003', 5.35, 16.16], ['Chile', 'Chile - 2009', 84.13, 81.04], ['Colombia', 'Colombia - 2010', 77.22, 71.67], ['Cook Islands', 'Cook Islands - 2011', 84.49, 71.6], ['Croatia', 'Croatia - 2009', 93.69, 90.6], ['Cuba', 'Cuba - 2010', 85.4, 85.6], ['Cyprus', 'Cyprus - 2009', 96.46, 94.65], ['Denmark', 'Denmark - 2009', 90.81, 88.02], ['Djibouti', 'Djibouti - 2008', 20.2, 28.17], ['Dominica', 'Dominica - 2007', 92.72, 83.64], ['Dominican Republic', 'Dominican Republic - 2010', 66.73, 58.04], ['Ecuador', 'Ecuador - 2007', 59.17, 58.18], ['Egypt', 'Egypt - 2002', 75.25, 79.58], ['El Salvador', 'El Salvador - 2010', 58.6, 56.58], ['Eritrea', 'Eritrea - 2010', 24.89, 32.38], ['Estonia', 'Estonia - 2009', 93.06, 91.06], ['Ethiopia', 'Ethiopia - 2001', 11.15, 16.86], ['Fiji', 'Fiji - 2007', 87.99, 79.33], ['Finland', 'Finland - 2009', 94.7, 93.89], ['France', 'France - 2009', 99.08, 97.4], ['Georgia', 'Georgia - 2009', 79.77, 83.93], ['Ghana', 'Ghana - 2011', 46.68, 50.56], ['Greece', 'Greece - 2007', 89.83, 90.52], ['Grenada', 'Grenada - 2008', 86.2, 95.06], ['Guatemala', 'Guatemala - 2010', 49.22, 51.07], ['Guinea', 'Guinea - 2009', 22.29, 36.46], ['Guinea-Bissau', 'Guinea-Bissau - 2000', 6.51, 11.64], ['Hong Kong', 'Hong Kong - 2010', 76.07, 74.58], ['Hungary', 'Hungary - 2009', 90.77, 91.41], ['Iceland', 'Iceland - 2009', 88.58, 86.64], ['Indonesia', 'Indonesia - 2010', 67.02, 67.54], ['Iraq', 'Iraq - 2007', 39.45, 48.91], ['Ireland', 'Ireland - 2009', 99.6, 97.03], ['Israel', 'Israel - 2009', 88.59, 86.48], ['Italy', 'Italy - 2009', 92.91, 92.77], ['Jamaica', 'Jamaica - 2010', 86.85, 80.42], ['Japan', 'Japan - 2009', 99.14, 98.67], ['Jordan', 'Jordan - 2008', 85.9, 82.57], ['Kazakhstan', 'Kazakhstan - 2011', 89.17, 89.95], ['Kenya', 'Kenya - 2009', 48.45, 51.59], ['Kiribati', 'Kiribati - 2005', 72.13, 65.28], ['Kuwait', 'Kuwait - 2008', 92.57, 85.74], ['Kyrgyzstan', 'Kyrgyzstan - 2010', 78.51, 79.31], ['Laos', 'Laos - 2008', 34.73, 39.12], ['Latvia', 'Latvia - 2010', 84.35, 83.05], ['Lebanon', 'Lebanon - 2010', 78.86, 70.63], ['Lesotho', 'Lesotho - 2010', 36.96, 22.82], ['Liechtenstein', 'Liechtenstein - 2009', 63.93, 65.23], ['Lithuania', 'Lithuania - 2009', 91.68, 90.35], ['Luxembourg', 'Luxembourg - 2008', 86.4, 83.82], ['Macao', 'Macao - 2010', 74.73, 77.68], ['Madagascar', 'Madagascar - 2008', 24.15, 23.05], ['Malawi', 'Malawi - 2010', 27.21, 27.85], ['Malaysia', 'Malaysia - 2009', 70.52, 65.46], ['Maldives', 'Maldives - 2002', 52.29, 45.7], ['Mali', 'Mali - 2011', 25.41, 36.31], ['Malta', 'Malta - 2009', 74.43, 78.24], ['Marshall Islands', 'Marshall Islands - 2007', 63.87, 60.49], ['Mauritania', 'Mauritania - 2007', 14.7, 17.08], ['Mauritius', 'Mauritius - 2004', 74.48, 73.69], ['Mexico', 'Mexico - 2009', 72.01, 68.97], ['Moldova', 'Moldova - 2010', 79.32, 77.96], ['Mongolia', 'Mongolia - 2009', 86.12, 79.75], ['Montserrat', 'Montserrat - 2007', 96.15, 95.11], ['Morocco', 'Morocco - 2003', 32.09, 37.98], ['Mozambique', 'Mozambique - 2010', 15.24, 16.99], ['Myanmar', 'Myanmar - 2010', 52.29, 49.33], ['Namibia', 'Namibia - 2007', 57.23, 44.17], ['Netherlands', 'Netherlands - 2009', 88.05, 86.68], ['Netherlands Antilles', 'Netherlands Antilles - 2002', 83.89, 76.22], ['New Zealand', 'New Zealand - 2010', 95.23, 94.28], ['Nicaragua', 'Nicaragua - 2010', 48.88, 42.73], ['Niger', 'Niger - 2008', 7.79, 12.67], ['Niue', 'Niue - 1999', 95.74, 90.91], ['Norfolk Island', 'Norfolk Island - 1999', 0.0, 0.0], ['Norway', 'Norway - 2009', 94.91, 94.6], ['Occupied Palestinian Territory', 'Occupied Palestinian Territory - 2010', 86.52, 80.64], ['Oman', 'Oman - 2009', 90.03, 89.47], ['Pakistan', 'Pakistan - 2010', 29.06, 38.44], ['Panama', 'Panama - 2010', 71.57, 66.01], ['Paraguay', 'Paraguay - 2009', 62.15, 58.0], ['Peru', 'Peru - 2009', 78.34, 78.42], ['Philippines', 'Philippines - 2009', 66.93, 56.42], ['Poland', 'Poland - 2009', 91.83, 90.24], ['Portugal', 'Portugal - 2006', 85.65, 77.82], ['Qatar', 'Qatar - 2010', 92.62, 76.08], ['South Korea', 'South Korea - 2009', 95.03, 96.2], ['Romania', 'Romania - 2009', 83.08, 81.56], ['Saint Kitts and Nevis', 'Saint Kitts and Nevis - 2010', 87.73, 88.9], ['Saint Lucia', 'Saint Lucia - 2010', 85.3, 85.32], ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines - 2008', 95.53, 85.3], ['Samoa', 'Samoa - 2010', 82.92, 73.2], ['Sao Tome and Principe', 'Sao Tome and Principe - 2011', 51.71, 44.36], ['Saudi Arabia', 'Saudi Arabia - 2010', 83.04, 78.41], ['Senegal', 'Senegal - 2006', 18.75, 24.42], ['Serbia', 'Serbia - 2010', 91.05, 89.32], ['Seychelles', 'Seychelles - 2008', 99.71, 91.55], ['Slovenia', 'Slovenia - 2009', 92.38, 91.35], ['Solomon Islands', 'Solomon Islands - 2007', 29.17, 32.4], ['South Africa', 'South Africa - 2000', 65.26, 58.6], ['Spain', 'Spain - 2009', 95.72, 92.77], ['Suriname', 'Suriname - 2009', 72.47, 52.92], ['Swaziland', 'Swaziland - 2010', 37.03, 28.72], ['Sweden', 'Sweden - 2009', 95.87, 95.79], ['Switzerland', 'Switzerland - 2009', 81.62, 84.94], ['Syria', 'Syria - 2010', 67.25, 66.75], ['Tajikistan', 'Tajikistan - 2010', 79.94, 89.82], ['Thailand', 'Thailand - 2011', 78.44, 69.86], ['Macedonia', 'Macedonia - 2005', 80.83, 82.48], ['Timor-Leste', 'Timor-Leste - 2010', 38.71, 34.43], ['Togo', 'Togo - 2000', 16.11, 33.3], ['Tonga', 'Tonga - 2004', 79.61, 66.99], ['Trinidad and Tobago', 'Trinidad and Tobago - 2004', 70.2, 66.31], ['Tunisia', 'Tunisia - 2001', 66.31, 64.02], ['Turkey', 'Turkey - 2009', 71.28, 76.91], ['Turks and Caicos Islands', 'Turks and Caicos Islands - 2005', 68.73, 71.67], ['Uganda', 'Uganda - 2004', 14.53, 16.5], ['Ukraine', 'Ukraine - 2010', 86.26, 85.75], ['United Arab Emirates', 'United Arab Emirates - 2006', 81.62, 80.49], ['United Kingdom', 'United Kingdom - 2009', 97.41, 94.71], ['United States of America', 'United States of America - 2010', 90.25, 88.78], ['Uruguay', 'Uruguay - 2008', 73.13, 66.13], ['Uzbekistan', 'Uzbekistan - 2009', 91.01, 92.97], ['Vanuatu', 'Vanuatu - 2010', 48.68, 46.21], ['Venezuela', 'Venezuela - 2010', 75.71, 68.0], ['Yemen', 'Yemen - 1999', 17.58, 44.02], ['Macedonia', 'Macedonia - 2005', 80.83, 82.48], ['Timor-Leste', 'Timor-Leste - 2010', 38.71, 34.43], ['Togo', 'Togo - 2000', 16.11, 33.3], ['Tonga', 'Tonga - 2004', 79.61, 66.99], ['Trinidad and Tobago', 'Trinidad and Tobago - 2004', 70.2, 66.31], ['Tunisia', 'Tunisia - 2001', 66.31, 64.02], ['Turkey', 'Turkey - 2009', 71.28, 76.91], ['Turks and Caicos Islands', 'Turks and Caicos Islands - 2005', 68.73, 71.67], ['Uganda', 'Uganda - 2004', 14.53, 16.5], ['Ukraine', 'Ukraine - 2010', 86.26, 85.75], ['United Arab Emirates', 'United Arab Emirates - 2006', 81.62, 80.49], ['United Kingdom', 'United Kingdom - 2009', 97.41, 94.71], ['United States of America', 'United States of America - 2010', 90.25, 88.78], ['Uruguay', 'Uruguay - 2008', 73.13, 66.13], ['Uzbekistan', 'Uzbekistan - 2009', 91.01, 92.97], ['Vanuatu', 'Vanuatu - 2010', 48.68, 46.21], ['Venezuela', 'Venezuela - 2010', 75.71, 68.0], ['Yemen', 'Yemen - 1999', 17.58, 44.02], ]); var options = { colorAxis: { colors: ['black', 'turquoise', 'white'], minValue: 0, maxValue: 100 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('secondaryeducationgeo_chart')); chart.draw(table, options); }; function drawGeoAdolescentFertilityRate() { var table = new google.visualization.DataTable(); table.addColumn('string', 'Country'); table.addColumn('number', 'Adolescent Fertility Rate (births / 1,000 women)'); table.addRows([['Afghanistan', 107.21], ['Albania', 16.09], ['Algeria', 6.58], ['Angola', 157.3], ['Argentina', 55.27], ['Armenia', 34.21], ['Aruba', 29.23], ['Australia', 14.1], ['Austria', 10.96], ['Azerbaijan', 32.36], ['The Bahamas', 29.69], ['Bahrain', 14.86], ['Bangladesh', 72.52], ['Barbados', 41.52], ['Belarus', 21.18], ['Belgium', 12.4], ['Belize', 73.96], ['Benin', 102.89], ['Bhutan', 47.0], ['Bolivia', 76.12], ['Bosnia and Herzegovina', 14.63], ['Botswana', 47.13], ['Brazil', 75.81], ['Brunei Darussalam', 23.67], ['Bulgaria', 38.86], ['Burkina Faso', 120.38], ['Burundi', 20.0], ['Cambodia', 36.44], ['Cameroon', 120.19], ['Canada', 12.34], ['Cape Verde', 74.14], ['Central African Republic', 101.83], ['Chad', 148.71], ['Channel Islands', 8.99], ['Chile', 56.89], ['China', 8.83], ['Colombia', 70.61], ['Comoros', 53.88], ['Democratic Republic of the Congo', 182.92], ['Republic of the Congo', 115.02], ['Costa Rica', 63.42], ['Cote d\'Ivoire', 115.16], ['Croatia', 13.06], ['Cuba', 44.44], ['Cyprus', 5.89], ['Czech Republic', 9.96], ['Denmark', 5.46], ['Djibouti', 20.88], ['Dominican Republic', 105.65], ['Ecuador', 81.45], ['Egypt', 43.02], ['El Salvador', 78.77], ['Equatorial Guinea', 117.92], ['Eritrea', 58.85], ['Estonia', 19.41], ['Ethiopia', 57.91], ['Fiji', 43.77], ['Finland', 9.33], ['France', 6.49], ['French Polynesia', 49.3], ['Gabon', 84.59], ['The Gambia', 70.75], ['Georgia', 41.56], ['Germany', 7.28], ['Ghana', 65.87], ['Greece', 10.41], ['Grenada', 38.22], ['Guam', 50.64], ['Guatemala', 104.31], ['Guinea', 143.15], ['Guinea-Bissau', 102.15], ['Guyana', 59.68], ['Haiti', 43.31], ['Honduras', 88.76], ['Hong Kong', 3.81], ['Hungary', 14.77], ['Iceland', 12.77], ['India', 79.33], ['Indonesia', 43.45], ['Iran', 26.78], ['Iraq', 90.72], ['Ireland', 12.29], ['Israel', 14.03], ['Italy', 5.06], ['Jamaica', 72.76], ['Japan', 5.63], ['Jordan', 24.81], ['Kazakhstan', 27.3], ['Kenya', 98.94], ['North Korea', 0.64], ['South Korea', 4.39], ['Kuwait', 14.16], ['Kyrgyz Republic', 33.43], ['Laos', 33.61], ['Latvia', 14.88], ['Lebanon', 15.73], ['Lesotho', 65.85], ['Liberia', 130.84], ['Libya', 2.8], ['Lithuania', 17.57], ['Luxembourg', 9.1], ['Macao', 4.11], ['Macedonia', 19.46], ['Madagascar', 127.31], ['Malawi', 111.05], ['Malaysia', 11.58], ['Maldives', 10.97], ['Mali', 175.87], ['Malta', 13.97], ['Mauritania', 74.5], ['Mauritius', 33.27], ['Mayotte', 100.89], ['Mexico', 67.54], ['Micronesia, Fed. Sts.', 21.24], ['Moldova', 31.01], ['Mongolia', 19.56], ['Montenegro', 16.16], ['Morocco', 12.54], ['Mozambique', 134.34], ['Myanmar', 13.7], ['Namibia', 62.43], ['Nepal', 93.08], ['Netherlands', 4.58], ['New Caledonia', 20.12], ['New Zealand', 23.51], ['Nicaragua', 107.99], ['Niger', 199.0], ['Nigeria', 114.13], ['North America', 30.94], ['Norway', 8.03], ['Oman', 9.28], ['Pakistan', 29.52], ['Panama', 78.57], ['Papua New Guinea', 63.94], ['Paraguay', 68.95], ['Peru', 51.12], ['Philippines', 49.53], ['Poland', 13.23], ['Portugal', 14.22], ['Puerto Rico', 51.89], ['Qatar', 15.75], ['Romania', 30.06], ['Russian Federation', 25.94], ['Rwanda', 36.76], ['Samoa', 26.63], ['Sao Tome and Principe', 59.68], ['Saudi Arabia', 17.85], ['Senegal', 96.2], ['Serbia', 20.39], ['Sierra Leone', 120.0], ['Singapore', 5.94], ['Slovak Republic', 18.11], ['Slovenia', 4.67], ['Solomon Islands', 66.89], ['Somalia', 68.85], ['South Africa', 53.92], ['South Asia', 72.78], ['Spain', 11.51], ['Sri Lanka', 22.68], ['St. Lucia', 58.18], ['St. Vincent and the Grenadines', 56.06], ['Sudan', 56.53], ['Suriname', 36.75], ['Swaziland', 74.3], ['Sweden', 6.31], ['Switzerland', 4.19], ['Syria', 39.03], ['Tajikistan', 26.79], ['Tanzania', 129.38], ['Thailand', 39.51], ['Timor-Leste', 57.67], ['Togo', 58.73], ['Tonga', 19.73], ['Trinidad and Tobago', 32.86], ['Tunisia', 4.88], ['Turkey', 33.94], ['Turkmenistan', 17.93], ['Uganda', 135.81], ['Ukraine', 27.97], ['United Arab Emirates', 24.73], ['United Kingdom', 29.7], ['United States', 32.9], ['Uruguay', 59.86], ['Uzbekistan', 13.18], ['Vanuatu', 51.97], ['Venezuela', 88.36], ['Vietnam', 24.35], ['Virgin Islands (U.S.)', 24.49], ['West Bank and Gaza', 50.4], ['Yemen', 71.18], ['Zambia', 141.81], ['Zimbabwe', 57.86], ]); var options = { colorAxis: { colors: ['white', '#B8004A'], minValue: 0 }, datalessRegionColor: 'white' }; var chart = new google.visualization.GeoChart(document.getElementById('adolescentfertilitygeo_chart')); chart.draw(table, options); };
</script><br />
<script type='text/javascript' src='https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221.0%22%2C%22callback%22%3A%22drawMaps%22%2C%22packages%22%3A%5B%22geochart%22%2C%22corechart%22%5D%7D%5D%7D'></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/the-vicious-cycle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino + RC car = Robocar</title>
		<link>http://www.malteahrens.com/blog/arduino-rc-car/</link>
		<comments>http://www.malteahrens.com/blog/arduino-rc-car/#comments</comments>
		<pubDate>Sat, 02 Jun 2012 10:42:47 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[EE]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robots]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=492</guid>
		<description><![CDATA[I have an old RC (remote controlled) car lying around, that I got a few years ago. The battery, being Ni-Cd (and not too well treated), is dying so it hasn&#8217;t seen much use lately. Earlier in the year, while taking part in Sebastian Thrun&#8217;s brilliant Programming a Robotic Car class, I got inspired to [...]]]></description>
				<content:encoded><![CDATA[<p>I have an old RC (remote controlled) car lying around, that I got a few years ago. The battery, being <a href="http://en.wikipedia.org/wiki/Nickel%E2%80%93cadmium_battery">Ni-Cd</a> (and not too well treated), is <i>dying</i> so it hasn&#8217;t seen much use lately. Earlier in the year, while taking part in Sebastian Thrun&#8217;s brilliant <a href="http://www.udacity.com/overview/Course/cs373/CourseRev/apr2012">Programming a Robotic Car</a> class, I got inspired to build my robot-car. Well, at least a model version.</p>
<p><iframe width="853" height="480" src="http://www.youtube.com/embed/gNpWKyiNDR0?rel=0" frameborder="0" allowfullscreen></iframe><br />
Where I&#8217;m currently at &#8211; that RC car controlled via an Arduino.</p>
<p>I saw David Singleton&#8217;s Neural-Networks Car, <a href="http://blog.davidsingleton.org/nnrccar">blog.davidsingleton.org/nnrccar</a>, and that&#8217;s where I decided to start &#8211; converting that old RC car into an Arduino controlled one. The key from David Singleton being, controlling the remote via Arduino rather than directly controlling the car via Arduino (which would probably require <s>some</s> a lot of disassembly of the plastic mold).</p>
<p>After taking apart the plastic shell of the remote, I needed to find how to connect up the Ardiuno. The method I used was:</p>
<ol>
<li>Find ground (or just use the negative terminal of the battery) and connect one end of a wire there</li>
<li>Look for the switches (forward / back, left / right) on the circuit board</li>
<li>With the car &#038; remote on, begin touching the other end of the wire to parts of the circuit and see what happens</li>
</ol>
<p>Once you&#8217;ve found that connection (you&#8217;ll notice that the car begins to move&#8230;), that&#8217;s (between there and ground) where you&#8217;d add the <a href="http://www.youtube.com/watch?v=-td7YT-Pums">transistor</a> (a transistor is like a tap, with the <i>base</i> being the valve). Setting the Arduino pin (which you connect to the <i>base</i>) to LOW or HIGH then controls whether current can flow through the transistor, in essence, an electronic switch.</p>
<p>After playing around with that for some time, and buying 90cents worth of transistors (the <a href="http://www.jaycar.com.au/productView.asp?ID=ZT2298">2N2222A NPN transistor</a>) I was able to get it to work (connecting the Arduino&#8217;s ground with the remote&#8217;s ground, and having the transistor the right way round, were two things that I learnt in particular).</p>
<p><a id="rss" style="border:0" href="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/arduino.png"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/arduino.png" style="border:0" /></a><br />
<i>Image based on Howard Logsdon&#8217;s work at <a href="http://wiki.hplogsdon.com/Arduino/">wiki.hplogsdon.com/Arduino/<a />. GPL licensed.</a></i></p>
<table style="padding-bottom:10px;max-width:900px">
<tr>
<td><a id="rss" style="border:0" href="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/arduinoremote.jpg"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/arduinoremote.jpg" alt="Arduino Remote" style="max-width:420px;border:0"/></a></td>
<td><a id="rss" style="border:0" href="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/circuitdiagram.jpg"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/circuitdiagram.jpg" alt="Circuit Diagram" style="max-width:450px;border:0"/></a><br />
<i>Made with <a href="http://www.circuitlab.com">circuitlab.com<a /></a></i></td>
</tr>
</table>
<p><span id="more-492"></span></p>
<p>Writing the code for the Arduino isn&#8217;t too difficult since you only need to turn the pins on (HIGH) or off (LOW), since that&#8217;s all that&#8217;s needed to make the transistors conduct. </p>
<p><code class="highlight">int left = 3;<br />int right = 5;<br />int back = 9;<br />int forward = 11;<br />
void loop() { }<br />
void setup()<br />{<br />  //set up all the pins as outputs<br />  pinMode(left,OUTPUT);<br />  pinMode(right,OUTPUT);<br />  pinMode(back,OUTPUT);<br />  pinMode(forward,OUTPUT);<br />
  //begin driving straight ahead...<br />  digitalWrite(forward, HIGH);<br />  delay(1000); //wait 1.0 seconds<br />
  //turn a bit to the left...<br />  digitalWrite(left, HIGH);<br />  delay(500); //wait 0.5 seconds<br />
  //turn a bit to the right...<br />  digitalWrite(left, LOW);<br />  digitalWrite(right, HIGH);<br />  delay(500); //wait 0.5 seconds<br />
  //drive ahead again...<br />  digitalWrite(left, LOW);<br />  delay(1000); //wait 1.0 seconds<br />
  //stop<br />  digitalWrite(forward,LOW);<br />}</code><br />
<!-- Initialise jQuery Syntax Highlighter --><br />
<script type="text/javascript">// < ![CDATA[
    $.SyntaxHighlighter.init();
// ]]&gt;</script></p>
<h3>What&#8217;s next?</h3>
<p>Currently, the Arduino / robocar is explicitly programmed, which is rather boring in comparison to giving it autonomy. So next up, I plan to experiment with using the Kinect&#8217;s depth image together with some code from Sebastian Thrun&#8217;s class&#8230;</p>
<p><img class="imagebox" src="http://www.malteahrens.com/blog/wp-content/uploads/2012/06/kinecthallway.jpg" alt="My hallway as the Kinect sees it"/><br />
My hallway (with a box in the way) as the Kinect sees it. Can you see the possibilities?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/arduino-rc-car/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Why Tablets?</title>
		<link>http://www.malteahrens.com/blog/why-tablets/</link>
		<comments>http://www.malteahrens.com/blog/why-tablets/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 06:34:47 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[OneNote]]></category>
		<category><![CDATA[Tablets]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=412</guid>
		<description><![CDATA[A few weeks ago I presented again at our school&#8217;s Computer Information Night(s) &#8211; annual nights where parents (and some students) come along to learn about the machine that will be purchased the following year, the financing, etc. Our school is a 1:1 school, so each student in year 5 (~10 years old+) and above [...]]]></description>
				<content:encoded><![CDATA[<p>A few weeks ago I presented again at our school&#8217;s Computer Information Night(s) &#8211; annual nights where parents (and some students) come along to learn about the machine that will be purchased the following year, the financing, etc. Our school is a 1:1 school, so each student in year 5 (~10 years old+) and above has their own tablet. As a student, I presented on why we actually use tablets, focusing on Years 5 to 12, and did a few OneNote demos. </p>
<div style="text-align:center">
<div style="display:inline-block;width:595px;">
<div id="__ss_10357632"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/malteahrens/why-tablets-2011-10357632" title="Why Tablets? | 2011" target="_blank">Why Tablets? | 2011</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/10357632?rel=0" width="595" height="410" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>
</div>
</div>
<p>PowerPoint: <a href="https://skydrive.live.com/view.aspx?cid=A45FE702DE180B23&#038;resid=A45FE702DE180B23!7420">https://skydrive.live.com/view.aspx?cid=A45FE702DE180B23&#038;resid=A45FE702DE180B23!7420</a><br />
OneNote Demos: <a href="https://skydrive.live.com/edit.aspx/Public/Demo?cid=a45fe702de180b23">https://skydrive.live.com/edit.aspx/Public/Demo?cid=a45fe702de180b23</a></p>
<p><span id="more-412"></span></p>
<hr />
<p>Having used my tablet (almost) exclusively for the past two and a half years, I felt that I needed to revisit some of the other technologies available for education.</p>
<p>I started off with paper, which because of its sheer versatility will likely be with us for a long time to come (that is until every surface becomes a &#8216;screen&#8217; as in <a href="http://www.microsoft.com/office/vision/">Microsoft&#8217;s Future Vision video</a>). Being cheap, light, and <i>everywhere</i>, it&#8217;s great for quickly jotting something down, demonstrating something, writing short notes, and the list goes on, but that&#8217;s about the only area where it comes out as the best &#8211; it&#8217;s messy (erasers don&#8217;t work 100%, you&#8217;re limited to a finite surface, you can&#8217;t easily add stuff from other sources, etc.) and difficult to organize. In the past year and a half, I&#8217;ve collected all the paper that we were given at school and that which we need to print out. Staggeringly, it comes to about 4000 sheets. That’s over 15kg of paper &#8211; more than enough to cover a tennis court! Very difficult to organize.</p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/11/Paper-Pile.jpg" alt="" class="imagebox" /></p>
<p>Next up I tried Apple&#8217;s iPad, which being nice and light and having a great battery life seemed like it could solve some of the organizational issues of paper, while keeping its versatility. In terms of hardware it is almost there (at least one USB port would be great though), except for one major issue &#8211; there is no <a href="http://en.wikipedia.org/wiki/Digitizer_tablet">digitizer</a>, i.e. no way for the OS to recognize that a stylus is touching the screen. There are some creative ways around this including the <a href="http://adonit.net/product/jot-pro/">Jot Pro</a> capacitive stylus and iOS apps that have a &#8216;zone&#8217; for you to rest your hand on (the program simply ignores the capacitive touches that the OS recognizes from that area), but the end result still looks like it was made with Microsoft Paint:</p>
<div style="text-align:center">
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/11/crop.png" alt="" class="imagebox" style="display:inline-block;" />
</div>
<p>So much for an improvement in neatness.</p>
<p>The iPad has some great apps that are very useful for discovering information like interactive periodic tables (<a href="http://itunes.apple.com/au/app/the-elements-a-visual-exploration/id364147847?mt=8">The Elements</a>), but in terms of research, where quick referencing and being able to see two things at once (ala Windows 8 split screen) are paramount, or for taking notes where it [the iPad] is little more than a glorified piece of paper, its not on par with OneNote on a Tablet (see below). </p>
<p><a href="http://tapose.com/">Tapose</a> (think Courier for the iPad) looks extremely promising and should address some of these issues (though will likely fall short for writing (with a stylus) due the iPad&#8217;s hardware (or lack thereof)).</p>
<p>Other students at school sometimes use Microsoft Word for taking notes in class, something that I do not completely understand. Sure, it&#8217;s a piece of software that most people are &#8216;familiar&#8217; with, but typing out notes and painstakingly using [Insert → Shapes → {shape}] (repeat), or taking down diagrams on a separate sheet of paper, is not only slow &#038; inflexible, but seems to perpetuate the idea that note-taking is like taking down a transcript. Students aren&#8217;t hansard&#8217;s (the people that transcribe everything said in parliament), and note-taking isn&#8217;t about transcribing everything &#8211; it&#8217;s about understanding. For the same reason why we sketch things before we go and make a mock-up, taking notes in low fidelity format, e.g. writing and drawing (by hand) helps us to understand. Using a high fidelity environment like Word, which was designed for printing not drawing, then impedes your learning because your focused on making the content look good, rather than understanding it.</p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/11/word.png" alt="" class="imagebox" /></p>
<hr />
<p>So that just leaves OneNote on a Windows tablet (the <a href="http://itunes.apple.com/us/app/microsoft-onenote/id410395246?mt=8">iOS app</a> is useful for little more than viewing rather than creating notes). It is not perfect, especially in terms of hardware (ultrabook-style tablets &#038; slates should improve on this though), spontaneity (grab tablet out of bag → remove pen → put password in → switch to OneNote) and interface (the ribbon interface, while being great for mouse input, does not work that well with touch, especially when using your finger), but for schools (especially higher education) it is the best that we have.</p>
<p><b>Portable:</b> A tablet with a weight generally under 2kg (or down to an almost-there 860 grams with the <a href="http://www.samsung.com/au/consumer/pc-peripherals/notebook-pc/thin-light/XE700T1A-A01AU/index.idx?pagetype=prd_detail">Samsung Series 7 Slate</a>) is rather portable, especially when compared to (in my case) about 10kg of books and pens. It means that whether I&#8217;m getting to school, moving around the school, or coming home again, all that I need to carry with me is my tablet. No printing (mostly, unfortunately), no paper (mostly, again unfortunately), and no heavy books.</p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/11/weights-print.png" alt="" /></p>
<p><b>Organized:</b> One of the primary advantages of doing work electronically is searchability. With OneNote&#8217;s ability to index text, ink, images, and audio, all my work is easily accessible (well most of the time &#8211; provided that I can remember what I&#8217;m looking for…, but still a lot easier than sifting from thousands of sheets of paper). With all my work in <i>one</i> place (exercise books, questions, solutions, web research, tests, scanned copies of exams, etc.), in OneNote , it is incredibly easy to back-up, and with SkyDrive, OneNote does it automatically &#8211; very useful in a school environment where things get lost and damaged.</p>
<p><b>Flexible:</b> Since this is a tablet, switching between text or touch input is as easy as raising your finger and touching the screen. This means that you can take your notes and draw diagrams in ink, and then with the same machine, and very quickly, start doing research (especially web searches), or work on that report, with the keyboard. Additionally, with OneNote, you can also drag-and-drop content (images, tables, text, etc.) onto the page. </p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/11/onenote.png" alt="" class="imagebox" style="margin-bottom:10px;"/></p>
<div style="margin-bottom:10px">
So, now that I have experimented with different options, I still believe that  OneNote and tablets are the superior choice for education, for their portability, flexibility and ability to keep information organized. That being said, I eagerly await Windows 8 slates (which should hopefully be fast and light) and OneNote 15 (and of course, any new unforeseen product).
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/why-tablets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s wrong with Pex4Fun&#8217;s Challenge?</title>
		<link>http://www.malteahrens.com/blog/whats-wrong-pex4fun-challenge/</link>
		<comments>http://www.malteahrens.com/blog/whats-wrong-pex4fun-challenge/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 09:04:05 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=336</guid>
		<description><![CDATA[Pex4Fun (www.pexforfun.com) lets you program in C#, Visual Basic, and F# from your browser or (Windows) Phone. Created by Microsoft Research , it&#8217;s a great tool for learning about programing. Learning is done through solving puzzles, for example working out the nth Hexagonal number or the Factorial of a number. Upon solving a puzzle, you [...]]]></description>
				<content:encoded><![CDATA[<p>Pex4Fun (<a href="http://www.pexforfun.com"><span style="color:blue; text-decoration:underline">www.pexforfun.com</span></a>) lets you program in C#, Visual Basic, and F# from your browser or (Windows) Phone. Created by Microsoft Research , it&#8217;s a great tool for learning about programing. Learning is done through solving <em>puzzles</em>, for example working out the <em>n<sup>th</sup></em> <a href="http://en.wikipedia.org/wiki/Hexagonal_number"><span style="color:blue; text-decoration:underline">Hexagonal number</span></a> or the <a href="http://en.wikipedia.org/wiki/Factorial"><span style="color:blue; text-decoration:underline">Factorial</span></a> of a number. Upon solving a puzzle, you can rate it Fun, Boring, or Fishy, and you get 2 extra points (your score gets put onto the leaderboard).</p>
<p> One challenge however, is a bit strange.</p>
<p>The challenge (<a href="http://www.pexforfun.com/Default.aspx?language=CSharp&#038;sample=ChallengeGeometricSeries"><span style="color:blue; text-decoration:underline"><em>ChallengeGeometricSeries</em></span></a>) asks you to work out the Geometric Series where the first value is 7, and the sum of the first two values is 21.
</p>
<p><span id="more-336"></span></p>
<hr />
<p>A geometric series is the sum of a collection of numbers that increase geometrically, i.e. by a common ratio. A geometric series is calculated by:
</p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/03/GeoSeries.png" height="51"/></p>
<p style="margin-left: 27pt">Where:
</p>
<ul style="margin-left: 54pt">
<li><em>x</em> is the number of terms to include (i.e. the first <em>x</em> terms)</li>
<li><em>Sum<sub>x</sub></em> is the sum of the first <em>x</em> terms
			</li>
<li><em>a</em> is the first value in the series
			</li>
<li><em>r</em> is the ratio between values
			</li>
</ul>
<p>For example if we want to know the sum of the first 5 powers of two (<em> 2 + 4 + 8 + 16 + 32 </em>) (which increase by a ratio of two) it would look like this:<br />
<br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/03/GeoSample.png" style="text-align:center" height="61"/>
</p>
<hr />
<p>Coming back to <em>Pex for fun</em>, using the sum formula above, we therefore know that the sum of the first <em>x</em> values will be:
</p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/03/GeoMain.png" style="text-align:center" height="51"/></p>
</p>
<p>What got me thinking was that it said that the <em>secret implementation result</em> where <em>x</em> is 63 (i.e. the sum of the first 63 values of the <em>secret</em> sequence) is <span style="font-family:Times New Roman"><em><strong>negative </strong>7</em>:<br />
		</span></p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/03/032611_0759_Whatswrongw1.png" alt=""/><span style="font-family:Times New Roman; font-size:12pt"><br />
		</span></p>
</p>
<p>Not only does the sum of the first 63 values <strong>not</strong> equal to  (they add up to approximately  <em>3.23 × 10<sup>19</sup></em>), but it is mathematically impossible to get a negative result (the ratio, <em>r</em>, is bigger than 1, therefore <em>r<sup>x</sup></em> will always be a positive number).
</p>
</p>
<p>Taking this to Visual Studio to do some debugging, the reason behind the <em>fishy</em> answer of <em>-7</em> clear. An <em>int</em> in C#, by default, is a signed 32-bit integer, i.e. its possible values are limited to between <em> -(2<sup>32</sup>) </em> and <em> 2<sup>31</sup> &#8211; 1 </em> (between <em> -2,147,483,648 </em> and <em> 2,147,483,647 </em>). Knowing this, it is clear why the <em>secret implementation result</em> is not the right answer (it is too big to store in an <em>int </em>data type), but why is it <strong>negative</strong> 7?</p>
</p>
<p>This is because in calculating the power through a loop, e.g.<br />
<code class="highlight">static int Power(int startnumber, int power)<br />{<br />&nbsp;int total = 1;<br />&nbsp;for (int i = 0; i &lt; power; i++)<br />&nbsp;&nbsp;total *= startnumber;<br />&nbsp;<br />&nbsp;return total;<br />}</code>
</p>
<p>Once the limit of a (32-bit) integer has been reached (obviously it would be better if the Puzzle method were to be a <em>double</em> rather than an <em>int</em>), rather than giving an exception, the number (in this case <em>total</em>) goes to zero. When this comes back to the <em>Puzzle </em>method, the return value becomes -7 because <img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/03/GeoExp.png" height="30" style="vertical-align:middle"/></p>
</p>
<p><code class="highlight">static int Puzzle(int x)<br />{<br />&nbsp;int a = 7;<br />&nbsp;int r = 2;<br />&nbsp;<br />&nbsp;return a * ((Power(r,x) - 1) / r - 1);<br />}</code><br />&nbsp;Fishy.<br />
<!-- Initialise jQuery Syntax Highlighter --><br />
<script type="text/javascript">
    $.SyntaxHighlighter.init();
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/whats-wrong-pex4fun-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing OneNote 2010 Add-Ins</title>
		<link>http://www.malteahrens.com/blog/howto-onenote-dev/</link>
		<comments>http://www.malteahrens.com/blog/howto-onenote-dev/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 11:13:59 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[OneNote]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=100</guid>
		<description><![CDATA[As with other Microsoft Office applications, you can also create add-ins for OneNote. In OneNote 2007 you wrote add-ins by implementing IOneNoteAddin (see Daniel Escapa&#8217;s tutorial &#8211; http://blogs.msdn.com/b/descapa/archive/2006/08/31/734298.aspx) and they integrated well with OneNote&#8217;s UI, being toolbar based add-ins in a toolbar based UI. With OneNote 2010&#8242;s ribbon, however, these &#8216;toolbar based&#8217; add-ins only show [...]]]></description>
				<content:encoded><![CDATA[<p>As with other Microsoft Office applications, you can also create add-ins for OneNote. In OneNote 2007 you wrote add-ins by implementing <em>IOneNoteAddin </em>(see Daniel Escapa&#8217;s tutorial &#8211; <a href="http://blogs.msdn.com/b/descapa/archive/2006/08/31/734298.aspx"><span style="color: blue; text-decoration: underline;">http://blogs.msdn.com/b/descapa/archive/2006/08/31/734298.aspx</span></a>) and they integrated well with OneNote&#8217;s UI, being toolbar based add-ins in a toolbar based UI.  With OneNote 2010&#8242;s ribbon, however, these &#8216;toolbar based&#8217; add-ins only show up on a separate Add-Ins tab, and even then only appearing as small icons. Integrating these add-ins with the ribbon / fluent UI is what we want for OneNote 2010, to properly &#8216;integrate&#8217; them with the UI. </p>
<p>Like this (a custom button in a custom tab in the ribbon):<br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_Final.png" alt="Add-in in Ribbon" /><br />
</p>
<p>This is a tutorial / guide on how to do this.</p>
<p>Rather not view this in a web browser? Ok, here&#8217;s the <a id="rss" href="http://www.malteahrens.com/Creations/Developing OneNote 2010 Addins.pdf">pdf</a> and <a id="rss" href="http://www.malteahrens.com/Creations/Developing OneNote 2010 Addins.xps">xps</a> documents of this tutorial</p>
<p><span id="more-100"></span></p>
<p>This has been tested with Visual Studio 2008 Professional and Visual Studio 2010 Professional.</p>
<ul>
<li><a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/HelloWorld-Visual-Studio-2008-Source.zip">Download the Visual Studio 2008 source code</a></li>
<li><a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/HelloWorld-Visual-Studio-2010-Source.zip">Download the Visual Studio 2010 source code</a></li>
</ul>
<hr />
<h3>Part 1 &#8211; Creating the project</h3>
<p>Whereas the “common” (not that OneNote isn’t) office programs, like Word, PowerPoint, Outlook, and Excel, all have VSTO (Visual Studio Tools for Office) templates, making it really easy to create add-ins for those programs. OneNote does not, but it does share a very similar add-in architecture. </p>
<ol>
<li>Open Visual Studio as Administrator (so that Visual Studio can register your add-in with COM Interop)</li>
<li>
<div>New Project → [Your Language of Choice] → Windows → Class Library</div>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_NewProject.png" alt="" /><br />
</p>
<div style="font-size:small">For this tutorial we will choose .NET 3.5 and C#, but you can choose what you want
	</div>
<p></p>
</li>
<li>
	First up we need to make the application COM-Visible<br />
	<!-- Image --></p>
<ol type="a">
<li>Right-Click on the Project  →  Properties<br />
		<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_RightClick-Properties.png"/>
		</li>
<li>Application tab  →  Assembly Information<br />
		<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_ApplicationTab.png"/>
		</li>
<li>Select ‘Make assembly COM-Visible’. This makes the class library / .dll generated by the project visible to OneNote.<br />
		<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_AssemblyInfo.png"/>
		</li>
<li>Click OK</li>
<li>Build tab  →  Register for COM Interop. This gets Visual Studio to automatically register the application for COM Interop when it’s built.<br />
		<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_Build.png"/>
		</li>
</ol>
</li>
<li>
To make debugging and building the project easier, we will change the AssemblyVersion attribute to automatically increment. This way, we won’t have to always update this attribute each time we want to update your application</p>
<ol type="a">
<li>Open: Properties  →  AssemblyInfo.cs<br />
	<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_AssemblyInfocs.png"/>
	</li>
<li>
		Change the following:<br />
		<code class="highlight">[assembly: AssemblyVersion("1.0.0.0")]<br />[assembly: AssemblyFileVersion("1.0.0.0")]</code><br />
		to:<br />
		<code class="highlight">[assembly: AssemblyVersion("1.0.*")]<br />[assembly: AssemblyFileVersion("1.0.*")]</code>
	</li>
</ol>
</li>
</ol>
<hr />
<h3>Part 2 &#8211; Creating the Ribbon</h3>
<p>The Fluent UI or Ribbon in Microsoft Office (the ‘new interface’) was launched with Office 2007 with the ‘common’ programs (again, not that OneNote isn’t) first – Word, PowerPoint, and Excel. In 2010 it came to the others, OneNote, Outlook, etc. Since the Fluent UI is controlled by an XML file, extending it (at least visually) is quite easy. So, our second step is to create an XML file that will contain this code to extend the ribbon:</p>
<ol>
<li>
<div>Add a XML file to the Add-In Project (Right Click  →  Add  →  Add New Item  →  Data  →  XML File). Call it something like <em>ribbon.xml</em></div>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_AddXML.png"/>
</li>
<li>
<div>To make this XML file readable by our add-in during runtime we will make it a resource (so that it is embedded in the .dll created).</div>
<ol type=a>
<li>
<div>Right Click on the Project  →  Properties  →  Resources  →  &#8216;Click here to create one&#8217;</div>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO3.png" alt="" /></p>
</li>
<li>
<div>Next, just Click-and-drag <em>ribbon.xml</em> into the Resources box</div>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO4.png" alt="" /></li>
</ol>
</li>
<li>
<div>MSDN has a great introduction to XML and the Ribbon. See: <a href="http://msdn.microsoft.com/en-us/library/aa338202).aspx"><span style="color: blue; text-decoration: underline;">http://msdn.microsoft.com/en-us/library/aa338202.aspx</span></a> Basically, we need a Tab (our own or an already existing one) to place our Group &#8211; a collection of controls &#8211; filled with our controls.</div>
</li>
<li>
The XML document to customize the ribbon starts with:</p>
<p><code class="highlight">&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />&lt;customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"&gt;<br />&nbsp;&lt;ribbon&gt;<br />&nbsp;&nbsp;&lt;tabs&gt;<br />&nbsp;&nbsp;&nbsp;&lt;!-- Our content goes here… --&gt;<br />&nbsp;&nbsp;&lt;/tabs&gt;<br />&nbsp;&lt;/ribbon&gt;<br />&lt;/customUI&gt;</code></p>
</li>
<li>
<div>In order to display images in the ribbon, they need to be parsed in a special way. We will do this later on in this guide, but we need to set-up the function so that we can do this. Just add the following attribute to the <em>&lt;CustomUI&gt;</em> element:</div>
<p><code class="highlight">loadImage="GetImage"</code><br />
so that it looks like this:<br />
<code class="highlight">&lt;customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="GetImage"&gt;<br />&nbsp;...<br />&lt;/customUI&gt;</code>
</li>
<li>
<div>In the ribbon, the first thing that we need is a <em>tab</em>. Either we can hook into an existing <em>tab</em> or we can create our own. For this demo we will create our own <em>tab</em>. If you want to extend an already existent <em>tab</em>, check out the Control IDs (<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3f2fe784-610e-4bf1-8143-41e481993ac6"><span style="color: blue; text-decoration: underline;">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3f2fe784-610e-4bf1-8143-41e481993ac6</span></a> ). Just replace <em>id=&quot;&quot;</em> with the <em>idMso=&quot;[the control id]</em>&quot; (without square brackets).</p>
<p>All that a <em>tab</em> needs is an <em>id</em> and a <em>label</em>:</div>
<p><code class="highlight">&lt;tab id="tabCustom" label="Custom"&gt;<br />&lt;/tab&gt;</code></p>
</li>
<li>
<div>Next we need a <em>group</em> in which to place our controls. Again this can be our own group or an already existing one. For this demo we will create our own Group. Again, all it needs is an <em>id</em> and a <em>label</em>:</div>
<p><code class="highlight">&lt;group id="groupHello" label="Hello"&gt;<br />&lt;/group&gt;</code></p>
</li>
<li>
<div>In this <em>group</em> we place our controls &#8211; for example Buttons, Menus, Checkboxes, etc. For this demo we will just add a simple button. Again it needs an <em>id</em> and a <em>label</em>, but we will also change (the next ones are optional) its <em>size</em> to large (for a big button), and add a tooltip. Also, we need to give it the path to the image and we need to give it an <em>onAction</em> function (basically the <em>OnClick()</em> event):</div>
<p><code class="highlight">&lt;button id="buttonHello" label="Hello World!" size="large" screentip="Press this for a 'Hello World!' message" onAction="showHello" image="HelloWorld.png" /&gt;</code></p>
</li>
<li>
<div>This is what it should look like now (like <a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/ribbon.xml_.txt">this</a>):</div>
<p><code class="highlight">&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />&lt;customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage=&quot;GetImage&quot;&gt;<br />&nbsp;&lt;ribbon&gt;<br />&nbsp;&nbsp;&lt;tabs&gt;<br />&nbsp;&nbsp;&nbsp;&lt;tab id="tabCustom" label="Custom"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;group id="groupHello" label="Hello"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;button id="buttonHello" label="Hello World!" size="large" screentip="Press this for a 'Hello World' message" onAction="showHello" image="HelloWorld.png"/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/group&gt;<br />&nbsp;&nbsp;&nbsp;&lt;/tab&gt;<br />&nbsp;&nbsp;&lt;/tabs&gt;<br />&nbsp;&lt;/ribbon&gt;<br />&lt;/customUI&gt;</code></p>
</li>
</ol>
<hr />
<h3>Part 3 &#8211; Writing some code</h3>
<p>With the ribbon done, next up we need to hook up the ribbon&#39;s events, and get<br />
our add-in to do something. </p>
<ol>
<li>
<div>Go to <em>Class1.cs</em> (you can rename it if you want, just be certain that if you change the class name public class <strong>[classname]</strong>), you update the ProgId as well)</div>
</li>
<li>
Add a reference (Right-Click on References → Add Reference…)<br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_AddRef.png"/><br />
to the following:</p>
<table>
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td>Tab
				</td>
<td>Name
				</td>
</tr>
<tr>
<td style="width:50px;"><strong>.NET<br />
				</strong>
				</td>
<td>
				Extensibility (note the capital E) (for the COM Add-In code)
				</td>
</tr>
<tr>
<td><strong>.NET</strong>
				</td>
<td>
				System.Windows.Forms (for a MessageBox)
				</td>
</tr>
<tr>
<td><strong>.NET</strong>
				</td>
<td>
				System.Drawing (for putting Images into the ribbon)
				</td>
</tr>
<tr>
<td><strong>COM</strong>
				</td>
<td>
				Microsoft OneNote 14.0 Object (<em>Type</em> for VS2008) Library (for the OneNote API)
				</td>
</tr>
<tr>
<td style="height: 23px"><strong>COM</strong>
				</td>
<td style="height: 23px">
				Microsoft Office 14.0 Object Library (for Ribbon Extensibility)
				</td>
</tr>
</table>
<p>
		<i>If you are using .NET 4 / VS 2010 be sure to turn off ‘Embed Interop Types’ for <strong>Microsoft OneNote 14.0 Object Library</strong>. See Daniel Escapa’s post on how and why: <a href="http://blogs.msdn.com/b/descapa/archive/2010/04/27/onenote-2010-and-visual-studio-2010-compatibility-issues.aspx">blogs.msdn.com/b/descapa</a></i></p>
</li>
<p></p>
<li>
<div>Add a using to the top of <em>Class1.cs</em>, among the other &#8216;usings&#8217;:</div>
<p><code class="highlight">using System.Runtime.InteropServices;</code></p>
</li>
<li>
Next, the Add-In requires a GUID to identify it. To create one:</p>
<ol type="a">
<li>Tools  →  Create GUID (if it isn’t there, do a search in the start-menu for <em>GUID</em>)</li>
<li>Choose Registry Format  →  Copy  →  Exit<br />
	<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_GUID.png"/>
	</li>
</ol>
</li>
<li>
Just above:<br />
<code class="highlight">public class Class1</code><br />
add:<br />
<code class="highlight">[GuidAttribute("[Your app’s Guid]"),ProgId("[Your app’s ProgId]")]</code><br />
[Your app’s Guid] = &lt;paste&gt; (without curly braces) the one created in Step 4<br />
[Your app’s ProgId] = <strong>Project.ClassName</strong> </p>
<p>Ensure that you have these values on hand (i.e. copied into Notepad, or even better OneNote) as they are needed for the setup project (later).</p>
</li>
<li>
<div>Add a using to the top of <em>Class1.cs</em>, among the other &#8216;usings&#8217;:</div>
<p><code class="highlight">using Extensibility;</code></p>
</li>
<li>
<div>This will allow us to implement <em>IDTExtensibility2 </em>(it contains all the COM Add-in functions), so that our code now looks like this:
</div>
<p><code class="highlight">public class Class1 : IDTExtensibility2<br />{ }</code></p>
</li>
<li>
Right-Click on IDTExtensibility2 (in the code (above) that we just added)  →  Implement Interface  →  Implement Interface. This will generate all the method stubs that the Add-In encounters during runtime<br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_ImpInterface.png" alt="" />
</li>
<li>
<div>So now there are a whole heap of stub methods with the code:</div>
<p><code class="highlight">throw new NotImplementedException();</code><br />
This needs to be removed; otherwise, when these methods are encountered during runtime, the application will exist because of these exceptions being thrown.</p>
<p>So delete them, that only the methods remain:<br />
<code class="highlight">public void OnAddInsUpdate(ref Array custom) { }<br />public void OnBeginShutdown(ref Array custom) { }<br />public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { }<br />public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom) { }<br />public void OnStartupComplete(ref Array custom) { }</code></p>
</li>
<li>
<div>Add a using to the top of <em>Class1.cs</em>, among the other &#8216;usings&#8217;:</div>
<p><code class="highlight">using Microsoft.Office.Interop.OneNote;</code></p>
</li>
<li>
<div>The <em>OnConnection()</em> function is called when the Add-In is being loaded. Here OneNote passes in the current instance of the <em>ApplicationClass</em>, the programmatic interface to OneNote’s API, so we set a new class-wide variable, <em>onApp</em>,<br />
	to equal it. </div>
<p><code class="highlight">ApplicationClass onApp = new ApplicationClass();<br />
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref System.Array custom)<br />{<br />&nbsp;onApp = (ApplicationClass)application;<br />}</code>
</li>
<li>
<div>To hook the ribbon&#8217;s events to our code we need to add:</div>
<p><code class="highlight">using Microsoft.Office.Core;</code>
</li>
<li>
<div>This will allow us to implement IRibbonExtensibility (it contains all the Ribbon functions), so that our code now looks like this:</div>
<p><code class="highlight">public class Class1 : IDTExtensibility2, IRibbonExtensibility<br />{<br />&nbsp;/* Code here… */<br />}</code>
</li>
<li>
<div>Right-Click on IRibbonExtensibility (in the code above that we just added)  →  Implement Interface  →  Implement Interface. This will create a stub of the Ribbon&#8217;s load event for us.</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO6.png" alt="" /></p>
</li>
<li>
<div>Replace the code:</div>
<p><code class="highlight">public string GetCustomUI(string RibbonID)<br />{<br />&nbsp;throw new NotImplementedException();<br />}</code></p>
<p>With returning the XML Resource (the <em>ribbon.xml</em> file) that we created in Step 2</p>
<p><code class="highlight">public string GetCustomUI(string RibbonID)<br />{<br />&nbsp;return Properties.Resources.ribbon;<br />}</code></p>
</li>
<li>
<div>Now to make the button work we create a function with the same name that we mentioned in the <em>ribbon.xml </em>for our button&#8217;s <em>onAction</em> event. It is important that this function is both <strong>public</strong> and takes an <strong>IRibbonControl</strong> as a parameter:</div>
<p><code class="highlight">public void showHello(IRibbonControl control)<br />{<br />}</code></p>
</li>
<li>
<div>This is the part where you can do what you want with your own code. This function will be called when the  (in our case) button is pressed. For this demo, we will just make it show a Messagebox with the current page&#8217;s ID.</div>
</li>
</ol>
<ol type=a>
<li>
<div>
			First add:</div>
<p>		<code class="highlight">using System.Windows.Forms;</code> </li>
<li>
<div>
			To get the <em>ID</em> of the current page, we call the <em>ApplicationClass</em> we created earlier:</div>
<p>		<code class="highlight">string id = onApp.Windows.CurrentWindow.CurrentPageId;</code>
		</li>
<li>
<div>
			And we will show it in a MessageBox</div>
<p>		<code class="highlight">MessageBox.Show("Current Page ID = " + id, "Hello World!");</code>
		</li>
</ol>
<li>
<div>
		To get an image to load on the ribbon, e.g. as the image of a button, we need to pass the image as an<br />
		<em>IStream</em></div>
<ol type=a>
<li>
<div>
			But first we need to add the image to our project (similarly to how we added<br />
			<em>ribbon.xml</em>)<em>.</em></div>
<ol type=i>
<li>Go to Resources (Right-Click on the Project  →  Properties  →  Resources)</li>
<li>
<div>
				Click on the down-arrow next to &#8216;Add Resource&#8217;, click &#8216;Add existing file&#8217;, and select the file (<a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/HelloWorld.png">HelloWorld.png</a>)</div>
<p style="margin-left: 27pt;">
			<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO7.png" alt="" /></p>
</li>
<li>
<div>
				In the Solution Explorer  →  Resources  →  right-click the inserted image  →  Properties  →  change its ‘Build Action’ to ‘Content’</div>
</li>
</ol>
</li>
<li>We start off by creating a new class (Right-Click on the project  →  Add  →  New Class). Call it CCOMStreamWrapper.cs</li>
<li>Paste in the following code (<a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/CCOMStreamWrapper.cs_.txt">CCOMStreamWrapper.cs</a>) written by Nani (Microsoft) (relevant blog link: <a href="http://blogs.msdn.com/b/johnguin/archive/2010/10/25/code-for-the-table-sorting-powertoy-for-onenote-2010.aspx"><span style="color: blue; text-decoration: underline;">http://blogs.msdn.com/b/johnguin/archive/2010/10/25/code-for-the-table-sorting-powertoy-for-onenote-2010.aspx</span></a> )that converts the image to an IStream</li>
<li>
<div>
			Going back to <em>Class1.cs</em>, next we need to use the function,<br />
			<em>GetImages()</em>, that we referenced in the <em>ribbon.xml</em> earlier</div>
<ol type=i>
<li>The function called, <em>GetImage()</em> needs an IStream of the image passed back. It provides one variable, the image name, that is the string specified in<br />
			<em>ribbon.xml</em> each time in the <em>image </em>attribute (for example in a button).</li>
<li>
<div>
				So first we add (for the <em>IStream </em>and <em>ImageFormat</em>):</div>
<p>			<code class="highlight">using System.Runtime.InteropServices.ComTypes;<br />using System.Drawing.Imaging;</code>
			</li>
<li>
<div>
				So we start off with an empty function (making sure that its name is the same as the one specified in<br />
				<em>ribbon.xml</em> load image attribute)<em>:</em></div>
<p>			<code class="highlight">public IStream GetImage(string imageName)<br />{&nbsp;}</code>
			</li>
<li>
<div>
				Next we need to create a memory stream, save the image to it (with the correct<br />
				<em>ImageFormat</em>), and return it (after it has been through the<br />
				<em>CCOMStreamWrapper</em> function):</div>
<p>			<code class="highlight">public IStream GetImage(string imageName)<br />{<br />&nbsp;MemoryStream mem = new MemoryStream();<br />&nbsp;Properties.Resources.HelloWorld.Save(mem, ImageFormat.Png);<br />&nbsp;return new CCOMStreamWrapper(mem);<br />}</code><br />
			<em>(where ImageName is the name of the image that you imported)</em>
			</li>
</ol>
</li>
</ol>
</li>
<li>
<div>
		When the application is closing, we want to ensure that we clear up the memory used. To do this, we:</div>
<ol type=a>
<li>
<div>
			Collect the &#8216;Garbage&#8217; with .NET&#8217;s GC (GarbageCollector) in the <em>OnDisconnection<br />
			</em>void</div>
<p>		<code class="highlight">public void OnDisconnection(ext_DisconnectMode disconnectMode, ref System.Array custom)<br />{<br />&nbsp;&nbsp;onApp = null;<br />&nbsp;&nbsp;GC.Collect();<br />&nbsp;&nbsp;GC.WaitForPendingFinalizers();<br />}</code>
		</li>
<li>
<div>
			Make our <em>ApplicationClass </em>variable (onApp) equal to null in the<br />
			<em>OnBeginShutdown </em>void</div>
<p>		<code class="highlight">public void OnBeginShutdown(ref System.Array custom)<br />{<br />&nbsp;&nbsp;if (onApp != null)<br />&nbsp;&nbsp;onApp = null;<br />}</code>
		</li>
</ol>
</li>
<li>Now, <em>Class1.cs</em> should look like (with a different <em>GUID</em> &#038; <em>ProgId</em>) <a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/Class1.cs_.txt">this</a></li>
<hr />
<h3>Part 4 &#8211; Fixing the Installer</h3>
<p>The last thing to do now is to create an installer. Office Add-ins use the registry to specify settings and link the dll with the Office application. The installer needs to create these registry keys, and copy the Project Output (the dll created) to the Program Files directory.
</p>
<ol>
<li>
<div>Add a Setup Project to the solution: File → Add → New Project → Other Project Types → Setup and Deployment → Visual Studio Installer → Setup Project</div>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_InstallProj.png"/>
</li>
<li>
<div>Click on the setup project, and choose &#8216;Registry Editor&#8217;</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_RegEdit.png" alt="" /></p>
</li>
<li>
<div>Remove all  the keys, so that only the default hives are left</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO10.png" alt="" /></p>
</li>
<li>Note your app’s GUID and ProgId, found in <em>Class1.cs</em><br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_GUIDandProgId.png"/>
</li>
<li>Create the following keys (Right-Click on a [Key / Hive]  →  Key) with their respective values (Right-Click  →  New  →  &lt;Type&gt;). Be sure to check their spelling &#8211; a common source of frustration when the add-in doesn&#8217;t load in OneNote</li>
<ul>
<li>HKEY_CLASSES_ROOT\AppID\[Your app&#39;s GUID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">DllSurrogate</td>
<td style="padding-left:5px"></td>
</tr>
</table>
<p>
	</li>
<li>HKEY_CLASSES_ROOT\CLSID\[Your app&#39;s GUID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">AppID</td>
<td style="padding-left:5px"><i>[Your app's GUID]</i></td>
</tr>
</table>
<p>
	</li>
<li>HKEY_CURRENT_USER\Software\Classes\AppID\[Your app&#39;s GUID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">DllSurrogate</td>
<td style="padding-left:5px"></td>
</tr>
</table>
<p>
</li>
<li>HKEY_CURRENT_USER\Software\Classes\CLSID\[Your app&#39;s GUID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">AppID</td>
<td style="padding-left:5px"><i>[Your app's GUID]</i></td>
</tr>
</table>
<p>
	</li>
<li>HKEY_LOCAL_MACHINE\Software\Classes\AppID\[Your app&#39;s GUID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">DllSurrogate</td>
<td style="padding-left:5px"></td>
</tr>
</table>
<p>
</li>
<li>HKEY_LOCAL_MACHINE\Software\Classes\CLSID\[Your app&#39;s GUID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">AppID</td>
<td style="padding-left:5px"><i>[Your app's GUID]</i></td>
</tr>
</table>
<p>
</li>
<li>HKEY_LOCAL_MACHINE\Software\Microsoft\Office\OneNote\AddIns\[Your app&#39;s ProgID]<br />
<table style="padding:5px;margin-left:20px;">
<tr style="font-weight:bold;background:#3441D2;color:white;padding:5px;">
<td style="width:70px;padding-left:5px;">Type</td>
<td style="width:100px;padding-left:5px;">Name</td>
<td style="width:170px;padding-left:5px;">Value</td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">Description</td>
<td style="padding-left:5px"><i>[Your app's description]</i></td>
</tr>
<tr>
<td style="padding-left:5px"><i>string</i></td>
<td style="padding-left:5px">FriendlyName</td>
<td style="padding-left:5px"><i>[Your app's name]</i></td>
</tr>
<tr>
<td style="padding-left:5px"><i>DWORD</i></td>
<td style="padding-left:5px">LoadBehavior</td>
<td style="padding-left:5px"><i>3</i></td>
</tr>
</table>
<p></p>
<div style="margin-left:20px;font-style:italic;">
		LoadBehavior should be &quot;9&quot; (load the add-in when the tab loads) for editing existing tabs  or &quot;3&quot; (load the add-in when the application loads) for newly created tabs. We are using &quot;3&quot; in this tutorial, because otherwise (if we used &quot;9&quot;) our tab would only load when the tab containing it would load, but because a tab is not contained in a tab, it would never load.</p>
<p>		For more information, see: <a href="http://msdn.microsoft.com/en-us/library/bb386106.aspx#LoadBehavior">http://msdn.microsoft.com/en-us/library/bb386106.aspx#LoadBehavior</a>
		</div>
<p></p>
<p>		If you don’t want to add all the keys to Visual Studio’s Registry Editor manually:</p>
<ol type="a">
<li>Open notepad and paste in the following code (<a id="rss" href="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/regkeys.reg_.txt">regkeys.reg</a>):
<div style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace;border:5px #ddd solid;padding:7px">Windows Registry Editor Version 5.00<br />&nbsp;<br />[HKEY_CLASSES_ROOT\AppID\[Your app’s GUID]]<br />&#8220;DllSurrogate&#8221;=&#8221;"<br />&nbsp;<br />[HKEY_CLASSES_ROOT\CLSID\[Your app’s GUID]]<br />&#8220;AppID&#8221;=&#8221;[Your app’s GUID]”<br />&nbsp;<br />[HKEY_CURRENT_USER\Software\Classes\AppID\[Your app’s GUID]]<br />&#8220;DllSurrogate&#8221;=&#8221;"<br />&nbsp;<br />[HKEY_CURRENT_USER\Software\Classes\CLSID\[Your app’s GUID]]<br />&#8220;AppID&#8221;=&#8221;[Your app’s GUID]”<br />&nbsp;<br />[HKEY_LOCAL_MACHINE\Software\Classes\AppID\[Your app’s GUID]]<br />&#8220;DllSurrogate&#8221;=&#8221;"<br />&nbsp;<br />[HKEY_LOCAL_MACHINE\Software\Classes\CLSID\[Your app’s GUID]]<br />&#8220;AppID&#8221;=&#8221;[Your app’s GUID]”<br />&nbsp;<br />[HKEY_LOCAL_MACHINE\Software\Microsoft\Office\OneNote\AddIns\[Your app’s ProgId]]<br />&#8220;Description&#8221;=&#8221;Press for a Hello World!&#8221;<br />&#8220;FriendlyName&#8221;=&#8221;Hello World!&#8221;<br />&#8220;LoadBehavior&#8221;=dword:00000003</div>
</li>
<li>Save the file as &lt;filename&gt;.reg (e.g. regkeys.reg)</li>
<li>&lt;Right-Click&gt; on ‘Registry on Target Machine’  →  Import…<br />
			<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_RegImport.png"/>
			</li>
<li>Find the save *.reg file and open it</li>
<li>Visual Studio will insert the keys and values for you
<p>			Be sure to check the imported values, sometimes (especially with the DWORD) insert doesn’t quite work)
</li>
</ol>
</li>
</ul>
<li>
<div>Now it should look like this (your <em>GUID </em>will be different, and your <em>ProgID</em> will probably be different to the one displayed here):</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_RegFinal.png" alt="" /></p>
</li>
<li>Click on the setup project, and choose ‘File System Editor’<br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_FileSysEdit.png"/>
</li>
<li>Second last, we need to add the project’s output (the dll created) to the install location:<br />
Click on the Application Folder (generally the \Program Files\ directory)  →  Right-Click  →  Add  →  Project Output…  →  OK<br />
<img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_AddOutput.png"/>
</li>
<li>
<div><b>Running 64-Bit Office?</b> Be sure to also change the <em>TargetPlatform</em> to <em>x64</em> in the Installer Properties (Click on the setup project  →  F4) <i> &#8211; Thanks for the tip, Ryan!</i></div>
</li>
<li>
<div>Change the installer setting (Click on the setup project  →  F4) <em>RemovePreviousVersions </em>to <em>True</em>. <br />You may also want to change some of the other settings, especially Product Name and Manufacturer, as the default install location is:<br /><em>[ProgramFilesFolder]\[Manufacturer]\[ProductName]</em></div>
</li>
</ol>
<h4>Done!</h4>
<p style="margin-bottom:15px;">So, now we are done with process in Visual Studio, so we just build the solution, install the setup project that it creates, and you should see your add-in in OneNote!</p>
<p><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/012711_1441_Final.png" alt="Add-in in Ribbon" /></p>
<p></p>
<hr />
<h3>Tips &amp; Good Sites</h3>
<p>Currently, when you want to debug the addin you need to change the Version of the Installer (as it checks for later versions before installing), build the solution, and install it. This can become very annoying when compiling frequently and attempting to debug an add-in. Speeding up this process (after the installer has run once, and made all the changes to the registry as necessary) you can get Visual Studio to simply build the project at its install location, thus not needing to constantly reinstall the application. To do this:</p>
<ol>
<li>
<div>First we will create a new Solution Configuration so that we can get Visual Studio to build the solution in the C:\Program Files path, while still  easily able to go back to our previous config where Visual Studio built the solution in the bin\debug folder. Go to Solution Configurations Selector  →  Configuration Manager</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO12.png" alt="" /></p>
</li>
<li>From the &#8216;active solution configuration&#8217;, choose &lt;New…&gt;</li>
<li>
<div>Create a new Solution Configuration, copying settings from &#8216;Debug&#8217;</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO13.png" alt="" /></p>
</li>
<li>Click OK, and Close</li>
<li>
<div>Right-Click on the Project  →  Properties</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO14.png" alt="" /></p>
</li>
<li>In Properties, go to the Debug tab. Change the <em>Output path</em> (under Output) to the install path of the application (generally <em>C:\Program Files\&lt;Manufacturer&gt;\&lt;ProductName&gt;\</em> )</li>
<li>
<div>Now simply build (Build  →  Build Solution) the project as normal, open OneNote again, and your add-in should have updated.</div>
</li>
</ol>
<h4>Note:</h4>
<ol>
<li>You may need to close <em>dllhost.exe</em> and OneNote before Visual Studio will allow you to build the project (files may be in use that would otherwise be overwritten)</li>
<li>
<div>If your addin hasn&#8217;t updated in OneNote, especially if the image in the ribbon hasn&#8217;t, &#8216;reload&#8217; the addin in OneNote. To do this:</div>
<ol type=a>
<li>
<div>File  →  Options  →  Add-Ins  →  (Manage: COM Add-Ins)  →  Go</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO15.png" alt="" /></p>
</li>
<li>
<div>Deselect your add-in and click OK (and OK in the OneNote Options window)</div>
<p style="margin-left: 27pt;"><img src="http://www.malteahrens.com/blog/wp-content/uploads/2011/01/011811_1025_DevelopingO16.png" alt="" /></p>
</li>
<li>Repeat the process (starting at <em>a</em>) again, but this time selecting your Add-In again</li>
<li>This generally works, as it gets OneNote to completely reload the add-in, thus (hopefully) loading the newer image for your add-in in the ribbon</li>
</ol>
</li>
</ol>
<h4>Useful links</h4>
<ul style="text-align:left">
<li>Debugging a OneNote Add-in with Visual Studio (for OneNote 2007 add-ins, but it&#8217;s still relevant): <a href="http://blogs.msdn.com/b/descapa/archive/2007/05/01/debugging-a-onenote-toolbar-addin-c.aspx"><span style="color: blue; text-decoration: underline;">http://blogs.msdn.com/b/descapa/archive/2007/05/01/debugging-a-onenote-toolbar-addin-c.aspx</span></a></li>
<p></p>
<li>Debugging OneNote API access through the log: <a href="http://blogs.msdn.com/b/descapa/archive/2006/12/08/debugging-the-onenote-api-enable-logging.aspx"><span style="color: blue; text-decoration: underline;">http://blogs.msdn.com/b/descapa/archive/2006/12/08/debugging-the-onenote-api-enable-logging.aspx</span></a></li>
<p></p>
<li>OneNote Error Codes / COM Exceptions: <a href="http://msdn.microsoft.com/en-us/library/ff966472.aspx"><span style="color: blue; text-decoration: underline;">http://msdn.microsoft.com/en-us/library/ff966472.aspx</span></a></li>
<p></p>
<li>Customizing the Ribbon / Fluent UI (for Office 2007, but it&#8217;s still relevant): <a href="http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx"><span style="color: blue; text-decoration: underline;">http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx</span></a></li>
<p></p>
<li>Getting the Control IDs for Tabs, Groups, and Buttons in OneNote&#8217;s ribbon (useful for e.g. adding a button on the Home tab, rather than a new tab): <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3f2fe784-610e-4bf1-8143-41e481993ac6&amp;displaylang=en"><span style="color: blue; text-decoration: underline;">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3f2fe784-610e-4bf1-8143-41e481993ac6&amp;displaylang=en</span></a></li>
<p></p>
<li>Editing content in OneNote through OneNote&#8217;s API: <a href="http://msdn.microsoft.com/en-us/magazine/ff796230.aspx"><span style="color: blue; text-decoration: underline;">http://msdn.microsoft.com/en-us/magazine/ff796230.aspx</span></a></li>
<p></p>
<li>OMSpy &#8211; taking a look at the XML structure of pages, sections (and section groups), and notebooks in OneNote: <a href="http://blogs.msdn.com/b/descapa/archive/2007/02/12/omspy-a-onenote-developer-s-tool.aspx"><span style="color: blue; text-decoration: underline;">http://blogs.msdn.com/b/descapa/archive/2007/02/12/omspy-a-onenote-developer-s-tool.aspx</span></a></li>
<p></p>
<li>Office Schema Reference (useful for trying to understand OneNote&#8217;s XML elements and attributes. It&#8217;s the 2007 one, but again it&#8217;s still relevant (and it provides it in a HTML format <strong>and</strong> *.xsd, whereas the 2010 one only has the *.xsd)): <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=15805380-F2C0-4B80-9AD1-2CB0C300AEF9&amp;displaylang=en"><span style="color: blue; text-decoration: underline;">http://www.microsoft.com/downloads/en/details.aspx?FamilyId=15805380-F2C0-4B80-9AD1-2CB0C300AEF9&amp;displaylang=en</span></a></li>
<p></p>
<li>Source Code from the Table Sorting Powertoy (by Nani &#8211; Microsoft): <a href="http://blogs.msdn.com/b/johnguin/archive/2010/10/25/code-for-the-table-sorting-powertoy-for-onenote-2010.aspx"><span style="color: blue; text-decoration: underline;">http://blogs.msdn.com/b/johnguin/archive/2010/10/25/code-for-the-table-sorting-powertoy-for-onenote-2010.aspx</span></a></li>
<p></p>
<li>All the OneNote blogs (especially <a href="http://blogs.msdn.com/johnguin/"><span style="color: blue; text-decoration: underline;">John Guin</span></a> and <a href="http://blogs.msdn.com/descapa/"><span style="color: blue; text-decoration: underline;">Daniel Escapa</span></a>)</li>
</ul>
<p><!-- Initialise jQuery Syntax Highlighter --><br />
<script type="text/javascript">
	$.SyntaxHighlighter.init();
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/howto-onenote-dev/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>OneNote + Tablets</title>
		<link>http://www.malteahrens.com/blog/onenote-and-tablets/</link>
		<comments>http://www.malteahrens.com/blog/onenote-and-tablets/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 04:55:41 +0000</pubDate>
		<dc:creator>Malte Ahrens</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[OneNote]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[Tablet PC]]></category>

		<guid isPermaLink="false">http://www.malteahrens.com/blog/?p=22</guid>
		<description><![CDATA[A few months ago (November 2010) I gave a presentation at our Computer Information Night(s), regarding the effective use of OneNote and Tablet PCs in a school environment. I have used Tablet PCs (primarily the Toshiba M405) for the past 3 years, and OneNote for 2 years and have seen a radical change in the way that I use and organize information.]]></description>
				<content:encoded><![CDATA[<p lang="en-US">A few months ago (November 2010) I gave a presentation at our Computer Information Night(s), regarding the effective use of OneNote and Tablet PCs in a school environment. I have used Tablet PCs (primarily the Toshiba M405) for the past 3 years, and OneNote for 2 years and have seen a radical change in the way that I use and organize information.</p>
<div style="text-align:center">
<div style="display:inline-block;width:595px;">
<div id="__ss_6555440"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/malteahrens/onenote-tablets" title="OneNote + Tablets" target="_blank">OneNote + Tablets</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/6555440?rel=0" width="595" height="497" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>
</div>
</div>
<p><span id="more-22"></span></p>
<p lang="en-US">Before beginning to use Tablet PCs in 2008, I had a &#8220;standard&#8221; laptop. Using folders and having multiple files for notes, articles, and other minor pieces of work, cluttered my &#8216;My Documents&#8217;  folder. Word documents full of class notes, over 10,000 words / 55 pages long, made it difficult to find information. Doing my mathematics work on paper / in exercise books, was messy and confusing, making it difficult to learn from notes, and previous mistakes. And then there was the amount of paper that was given out. I don&#8217;t have an exact number of how much, but considering that last year, a year during which I exclusively used my Tablet, I went through roughly 1,000 sheets of paper, the vast majority being handouts, it certainly was a lot of paper.</p>
<p lang="en-US">This became too much for in early 2010, so I decided to use my Tablet PC for all my school work. I was able to put feelings of being overwhelmed by paper, loosing or &#8216;misplacing&#8217; pieces of paper, and the messiness of things everywhere, behind me, largely through the use of OneNote.</p>
<p lang="en-US">The three main reasons why I choose to use OneNote were:</p>
<ol>
<li><strong>Easy to backup</strong><br />
Paper gets lost. Paper gets damaged. (Most) work on your machine isn&#8217;t &#8216;backed-up&#8217; all the time. It can be lost through viruses, and is &#8216;stuck&#8217; in this one location (on your harddrive). OneNote on the other hand, not only keeps all your notebooks (by default) in a single folder, making for easy backups of your work, but also makes it easy to synchronize your work with the Cloud, using Office Live &#8211; automatically synchronizing your work, and enabling access from multiple devices (through PCs, the Internet, and Windows Phone). See Shared Notebooks: <a href="http://office.microsoft.com/en-us/onenote-help/share-notebooks-in-onenote-2010-HA010386952.aspx" target="_blank">http://office.microsoft.com/en-us/onenote-help/share-notebooks-in-onenote-2010-HA010386952.aspx</a></li>
<li><strong>Easy to organize</strong><br />
You can&#8217;t easily find something in a pile of paper. Searching for a phrase in a collection of documents full of notes doesn&#8217;t always return relevant and timely results. OneNote, however, allows for quick and relevant searches throughout all you documents, including text, images, and ink. OneNote makes it simple to tag relevant selections of text, ink and images, making it easy to find (for example) all quotations in a History Notebook. See Tagging: <a href="http://www.addictivetips.com/microsoft-office/onenote-2010-tagging-guide/">http://www.addictivetips.com/microsoft-office/onenote-2010-tagging-guide/</a></li>
<li><strong>Easy to take brilliant notes</strong><br />
Taking notes on paper or in a Word document, frequently results in a collection of different documents of notes, completely separate from their context and relevance. OneNote makes it easy to take notes where the context is automatically saved. Also, by letting you write anywhere on a page, not restricting you to Top to Bottom, linear, content, as well as supporting inking,  OneNote makes it easy to take brilliant notes quickly. See Linked Notes: <a href="http://www.onenotehelp.com/2009/11/19/take-linked-notes-in-onenote-2010/">http://www.onenotehelp.com/2009/11/19/take-linked-notes-in-onenote-2010/</a></li>
</ol>
<p lang="en-US">So, with all my notes in OneNote on my Tablet PC, synced with Office Live, I have been able to organize my school life without being in a mess of paper, loosing paper, or being overwhelmed by paper.</p>
<p lang="en-US">I haven&#8217;t look back.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.malteahrens.com/blog/onenote-and-tablets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
