<?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>metcaffeination &#187; doing the math</title>
	<atom:link href="http://metcaffeination.net/weblog/category/doing-the-math/feed/" rel="self" type="application/rss+xml" />
	<link>http://metcaffeination.net/weblog</link>
	<description>cities. physics. food. environment. fatherhood.</description>
	<lastBuildDate>Mon, 08 Feb 2010 04:45:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DC intersections with Mathematica</title>
		<link>http://metcaffeination.net/weblog/2009/03/01/dc-intersections-with-mathematica/</link>
		<comments>http://metcaffeination.net/weblog/2009/03/01/dc-intersections-with-mathematica/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 05:07:08 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[DC]]></category>
		<category><![CDATA[doing the math]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=221</guid>
		<description><![CDATA[Without the quadrant designation, several intersections in Washington&#8211;&#8221;6th and C,&#8221; for example&#8211;are ambiguous. &#8220;6th and C&#8221; can refer to a place in NW, NE, SW, or SE DC. Because of this duplication of streets and intersections, the quadrant is usually&#8211;but not always&#8211;specified. I&#8217;ve been curious  for some time to know exactly how many doubly-, triply-, and quadruply-redundant [...]]]></description>
			<content:encoded><![CDATA[<p>Without the quadrant designation, several intersections in Washington&#8211;&#8221;6th and C,&#8221; for example&#8211;are ambiguous. &#8220;6th and C&#8221; can refer to a place in NW, NE, SW, or SE DC. Because of this duplication of streets and intersections, the quadrant is usually&#8211;but not always&#8211;specified. I&#8217;ve been curious  for some time to know exactly how many doubly-, triply-, and quadruply-redundant intersections there are in DC, and it&#8217;s another fun example combining <a href="http://www.wolfram.com/products/mathematica/index.html">Mathematica 7</a>&#8217;s <a href="http://reference.wolfram.com/mathematica/ref/format/SHP.html">.shp</a> file import with the GIS data that the <a href="http://dcgis.dc.gov/dcgis/site/default.asp">DC government makes available</a>.</p>
<p>How many are there? I calculate:</p>
<table border="0">
<tbody>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span>Quadrants:</span></td>
<td style="text-align: center;"><span>2</span></td>
<td style="text-align: center;"><span>3</span></td>
<td style="text-align: center;"><span>4</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span>Intersections:</span></td>
<td style="text-align: center;"><span>418</span></td>
<td style="text-align: center;"><span>71</span></td>
<td style="text-align: center;"><span>28</span></td>
</tr>
</tbody>
</table>
<p>The 28 intersections that appear in all 4 quadrants are:</p>
<blockquote><p>14th &amp; D, 9th &amp; G, 7th &amp; I, 7th &amp; E, 7th &amp; G, 7th &amp; D, 6th &amp; C, 6th &amp; G, 6th &amp; D, 6th &amp; I, 6th &amp; E, 4th &amp; M, 4th &amp; G, 4th &amp; E, 4th &amp; D, 4th &amp; I, 3rd &amp; M, 3rd &amp; C, 3rd &amp; K, 3rd &amp; D, 3rd &amp; G, 3rd &amp; E, 3rd &amp; I, 2nd &amp; E, 2nd &amp; C, 1st &amp; M, 1st &amp; C, 1st &amp; N</p></blockquote>
<p>Plotted on a map:</p>
<p> </p>
<div id="attachment_223" class="wp-caption aligncenter" style="width: 410px"><img class="size-full wp-image-223" title="intersectionmap" src="http://metcaffeination.net/weblog/wp-content/uploads/2009/02/intersectionmap.jpg" alt="Color coded map of intersections in DC." width="400" height="492" /><p class="wp-caption-text">Color coded map of intersections in DC.</p></div>
<p><strong>Update:</strong> Here&#8217;s a <a href="http://metcaffeination.net/weblog/wp-content/uploads/2009/03/intersectionmap_large.pdf">larger PDF version</a>.</p>
<p>Here&#8217;s how I made the map and did the calculations:</p>
<p><span id="more-221"></span></p>
<p>I started with the same <a href="http://data.octo.dc.gov/Metadata.aspx?id=122">Street Centerline</a> file that I used in my <a href="http://metcaffeination.net/weblog/2009/01/17/red-street-blue-street/">first post on GIS with Mathematica</a>. The elements of this file are lines representing street segments between intersections, so the first and the last point defining each line lie at intersections. First, I take from the rather unwieldy raw data and make a new list where each element corresponds to one street segment, and within each of these elements, the geometry is followed by all the other data:<br />
<code><br />
dcstreets=Import["StreetSegmentsLn.shp","Data"][[1]];<br />
dcstreetdata =<br />
Transpose[Join[{dcstreets[[2, 2]]}, dcstreets[[4, 2, All, 2]]]];<br />
</code><br />
Then I wrote two functions to pick off the data I need: for each of the first and last points, representing the locations of the intersections, I need the street name, type (e.g. Street or Avenue), and quadrant:<br />
<code><br />
nodeFunction = Join[{#[[1, 1, 1]]}, #[[6 ;; 8]]] &amp;<br />
tailFunction = Join[{#[[1, 1, -1]]}, #[[6 ;; 8]]] &amp;<br />
nodelist =<br />
Union[Join[Map[nodeFunction, dcstreetdata],<br />
Map[tailFunction, dcstreetdata]]];<br />
</code><br />
<code>Map</code> applies the specified function to each item in the list of street segments, and the resulting lists of beginning and ending intersections from all the segments are put together with <code>Join</code>. Of course, most streets run through numerous intersections, and the second intersection of one segment will be the first intersection of the next segment. To make sure we get the beginning and ending of each street, we do need both the first and second intersection from each, and we use <code>Union</code> to remove all the duplicates from the middle.</p>
<p>We now have a list in which each element contains a location and street name. We now need a list of all the intersections&#8211;when two streets share the same point. Fortunately, Mathematica 7 introduced the <code><a href="http://reference.wolfram.com/mathematica/ref/GatherBy.html">GatherBy</a></code> function, which groups a list depending on the value each element returns from the specified function. In this case, the specified function is just the first element, that is, the location:<br />
<code><br />
intersections = GatherBy[nodelist, #[[1]] &amp;];<br />
In[]:= BinCounts[Length /@ intersections, {1, 6, 1}]<br />
Out[]:= {901, 7015, 491, 20, 2}<br />
</code><br />
The second line tells us that there are 901 end-points with only one street (the majority, I believe, are where the streets lead outside the District boundary), 7015 points where two streets come together; 491 points where three, 20 points where four, and 2 points where 5 streets come together. Which are these? With<br />
<code><br />
Select[intersections, Length[#] == 5 &amp;]<br />
</code><br />
We find that the first is the intersection of 15th Street, Benning Road, Bladensburg Road, H Street, and Maryland Avenue NE, while the second is the intersection of 51st Street, Doewood Lane, Eastern Avenue, Mann Street, and Meade Street NE.<sup>1</sup> For our purposes, we want to consider all these as pairs, so we break all intersections with three or more streets into their respective pairs:<br />
<code><br />
intersectionPairs =<br />
Flatten[Join[Subsets[#, {2}] &amp; /@ intersections], 1];<br />
</code><br />
Since I&#8217;m using the Street Centerline File, the streets that serve as quadrant boundaries&#8211;North Capitol, East Capitol, and South Capitol streets&#8211;are not given a quadrant but given the designation &#8220;BN&#8221; for boundary. Actual addresses on these streets are given a quadrant depending on which side of the street they&#8217;re on. In this scheme, you&#8217;ll get intersections such as 17th Street NE and 17th Street SE, where they intersect East Capitol Street. I&#8217;m ignoring those for this exercise, and then using <code>GatherBy</code> again to find all the points where the intersection street names are the same:<br />
<code><br />
quadrantPairs = Select[intersectionPairs, #[[1, 4]] == #[[2, 4]] &amp;];<br />
multipoint =<br />
GatherBy[quadrantPairs, {#[[1, 2 ;; 3]], #[[2, 2 ;; 3]]} &amp;];<br />
</code><br />
Looking at the structure of this we see a little more work to be done:<br />
<code><br />
In[]:= BinCounts[Length /@ multipoint, {1, 7, 1}]<br />
Out[]:= {6287, 741, 101, 36, 7, 1}<br />
</code><br />
Which tells us that there are 6287 unique intersections in DC, appearing in only one quadrant; 741 that appear in two quadrants, and 1 that appears in 6 quadrants???</p>
<p>This happened because Stanton Square is considered to be a giant median for C Street NE, so there are actually three distinct points that could be considered the corner of 6th and C Streets NE, all along one block. There are also intersections of 6th and C streets in NW, SE, and SW, giving a total of 6. For this, though, I want to treat all the locations in NE as the same, so I make my lists of quadruply, triply, and doubly-redundant intersections depending on how many quadrants appear, which I count with <code>Length</code> and <code>Union</code>:<br />
<code><br />
quads = Select[multipoint,<br />
Length[Union[Flatten[#[[All, All, 4]]]]] == 4 &amp;];<br />
triples =<br />
Select[multipoint, Length[Union[Flatten[#[[All, All, 4]]]]] == 3 &amp;];<br />
doubles =<br />
Select[multipoint, Length[Union[Flatten[#[[All, All, 4]]]]] == 2 &amp;];<br />
</code><br />
Giving lists of intersections, the lengths of which were quoted above. Relatively simple graphics commands made the figure, to which I added the <a href="http://data.octo.dc.gov/Metadata.aspx?id=74">DC Boundary</a> polygon from another .shp file.</p>
<p>Figuring this out took far more lines of code than the modestly few lines that I can reproduce this exercise with. The keys were learning to use the new <code>GatherBy</code> function and getting used to the idea of <code>Union</code> as a list management tool, as opposed to simply part of the set theory functionality. And as usual, knowing how to use <code>Map</code> and pure functions are necessary for doing almost anything elegantly in Mathematica.</p>
<ol class="footnotes"><li id="footnote_0_221" class="footnote">Doewood and Mann are actually the names of 51st and Meade Streets when they cross Eastern Avenue into Maryland, however I believe DC responsibility actually extends 50 feet or so beyond Eastern Avenue, hence the inclusion in the GIS data.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2009/03/01/dc-intersections-with-mathematica/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Red Street, Blue Street</title>
		<link>http://metcaffeination.net/weblog/2009/01/17/red-street-blue-street/</link>
		<comments>http://metcaffeination.net/weblog/2009/01/17/red-street-blue-street/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 17:47:11 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[DC]]></category>
		<category><![CDATA[doing the math]]></category>
		<category><![CDATA[politics]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=206</guid>
		<description><![CDATA[In the end, I went with the upgrade to Mathematica 7. Of all the new features, the one that really hooked me&#8211;which is comparatively minor, compared to all the other new features&#8211;is the ability to import SHP files. The importation is not terribly well documented nor is there much additional support, but it was pretty [...]]]></description>
			<content:encoded><![CDATA[<p>In the end, I went with the upgrade to <a href="http://wolfram.com/products/mathematica/index.html">Mathematica 7</a>. Of all the new features, the one that really hooked me&#8211;which is comparatively minor, compared to all the other new features&#8211;is the ability to import SHP files. The importation is not terribly well documented nor is there much additional support, but it was pretty easy to do a few nifty things with the  <a href="http://data.octo.dc.gov/Metadata.aspx?id=122">DC Street Centerline</a> file.</p>
<p>As you may know, there is a street in DC for every state in the union. Pennsylvania Avenue is probably the most famous of these; the White House sits at 1600 Pennsylvania Ave NW. I used to live on Massachusetts Avenue. So my first idea was to make a street map of DC in which the state-named streets were colored red-ish or blue-ish depending on their vote in the recent election.</p>
<p>Here it is:<br />
<img class="aligncenter size-full wp-image-208" title="redbluestreet_1" usemap="#map_1" src="http://metcaffeination.net/weblog/wp-content/uploads/2009/01/redbluestreet_1.gif" alt="" width="400" height="495" /></p>
<map name='map_1'>
<area shape='rect' coords='118,197,150,185' title='WYOMING' nohref />
<area shape='rect' coords='62,232,111,84' title='WISCONSIN' nohref />
<area shape='rect' coords='229,231,267,190' title='WEST VIRGINIA' nohref />
<area shape='rect' coords='101,368,238,179' title='WASHINGTON' nohref />
<area shape='rect' coords='114,289,238,228' title='VIRGINIA' nohref />
<area shape='rect' coords='155,236,182,187' title='VERMONT' nohref />
<area shape='rect' coords='98,86,122,51' title='UTAH' nohref />
<area shape='rect' coords='278,313,341,254' title='TEXAS' nohref />
<area shape='rect' coords='239,259,257,236' title='TENNESSEE' nohref />
<area shape='rect' coords='205,194,311,87' title='SOUTH DAKOTA' nohref />
<area shape='rect' coords='214,279,257,260' title='SOUTH CAROLINA' nohref />
<area shape='rect' coords='144,223,295,146' title='RHODE ISLAND' nohref />
<area shape='rect' coords='113,323,326,218' title='PENNSYLVANIA' nohref />
<area shape='rect' coords='120,91,131,28' title='OREGON' nohref />
<area shape='rect' coords='266,251,283,236' title='OKLAHOMA' nohref />
<area shape='rect' coords='118,335,186,249' title='OHIO' nohref />
<area shape='rect' coords='190,89,207,74' title='NORTH DAKOTA' nohref />
<area shape='rect' coords='208,276,261,246' title='NORTH CAROLINA' nohref />
<area shape='rect' coords='143,246,335,185' title='NEW YORK' nohref />
<area shape='rect' coords='58,175,76,146' title='NEW MEXICO' nohref />
<area shape='rect' coords='187,296,220,195' title='NEW JERSEY' nohref />
<area shape='rect' coords='119,243,223,74' title='NEW HAMPSHIRE' nohref />
<area shape='rect' coords='85,98,106,62' title='NEVADA' nohref />
<area shape='rect' coords='33,188,127,63' title='NEBRASKA' nohref />
<area shape='rect' coords='221,203,273,170' title='MONTANA' nohref />
<area shape='rect' coords='147,107,210,82' title='MISSOURI' nohref />
<area shape='rect' coords='206,399,278,363' title='MISSISSIPPI' nohref />
<area shape='rect' coords='249,316,354,206' title='MINNESOTA' nohref />
<area shape='rect' coords='182,174,268,120' title='MICHIGAN' nohref />
<area shape='rect' coords='34,309,338,115' title='MASSACHUSETTS' nohref />
<area shape='rect' coords='164,275,282,217' title='MARYLAND' nohref />
<area shape='rect' coords='151,292,190,259' title='MAINE' nohref />
<area shape='rect' coords='196,255,213,239' title='LOUISIANA' nohref />
<area shape='rect' coords='239,286,261,256' title='KENTUCKY' nohref />
<area shape='rect' coords='165,151,216,67' title='KANSAS' nohref />
<area shape='rect' coords='155,135,179,107' title='IOWA' nohref />
<area shape='rect' coords='180,252,205,242' title='INDIANA' nohref />
<area shape='rect' coords='168,145,196,96' title='ILLINOIS' nohref />
<area shape='rect' coords='75,167,96,132' title='IDAHO' nohref />
<area shape='rect' coords='204,140,227,119' title='HAWAII' nohref />
<area shape='rect' coords='168,198,187,29' title='GEORGIA' nohref />
<area shape='rect' coords='129,236,256,181' title='FLORIDA' nohref />
<area shape='rect' coords='193,300,221,217' title='DELAWARE' nohref />
<area shape='rect' coords='78,236,157,71' title='CONNECTICUT' nohref />
<area shape='rect' coords='136,133,174,85' title='COLORADO' nohref />
<area shape='rect' coords='118,200,152,187' title='CALIFORNIA' nohref />
<area shape='rect' coords='153,144,176,108' title='ARKANSAS' nohref />
<area shape='rect' coords='21,178,47,153' title='ARIZONA' nohref />
<area shape='rect' coords='153,59,177,30' title='ALASKA' nohref />
<area shape='rect' coords='220,371,344,270' title='ALABAMA' nohref />
</map>
<p>Read on to see how I made it:</p>
<p><span id="more-206"></span></p>
<p>I imported election returns from <a href="http://en.wikipedia.org/wiki/United_States_presidential_election,_2008">Wikipedia</a>, but the process of picking the data I wanted out of the whole <code>Import</code> was so ugly that I&#8217;m not going to step through it here. I was inspired, though, by <a href="http://blog.wolfram.com/2008/09/24/analyzing-us-2008-elections-with-mathematica/">this similar post</a> on the Wolfram blog. If anyone at Wolfram is listening: it&#8217;d be really great if we could import data from the web by, say, clicking on a table of a web page displayed in a browser, instead of picking out which item in some nested list is the one we want.</p>
<p>From the raw vote data, I computed the (approximate) percentage of the vote that Obama got:<sup>1</sup><br />
<code><br />
ntrs[x_] := N[ToExpression[StringReplace[x, "," -&gt; ""]]]<br />
percentData = {ToUpperCase[#[[1]]], ntrs[#[[2]]]/(ntrs[#[[2]]] + ntrs[#[[3]]])} &amp; /@ votedata<br />
</code><br />
Which gives a list of things like<br />
<code><br />
{"CALIFORNIA", 0.622799}</code>.<br />
The conversion to uppercase is to match the way the DC street names are recorded.</p>
<p>I&#8217;ll need a list of states, in order to match the street names. I get this from Mathematica&#8217;s curated <code>CountryData</code> data set, using a Regular Expression to insert a space any time there&#8217;s a lowercase letter followed by an uppercase letter, to change, for example, &#8220;NewJersey&#8221; into &#8220;New Jersey&#8221;:<br />
<code><br />
states = StringReplace[#, RegularExpression["([a-z])([A-Z])"] -&gt; "$1 $2"] &amp; /@ CountryData["United States", "Regions"]<br />
</code></p>
<p>And the street datafile itself. When Mathematica imports SHP files, it returns a list of layers; with only one layer in this file, we get a (long) list with one element. So I specify in the <code>Import</code> that I only want this first (and only) element of the list:<br />
<code><br />
dcstreets=Import["StreetSegmentsLn.shp","Data"][[1]];<br />
</code><br />
And this gives a list of 4 replacement rules, some of which are very long:<br />
<code><br />
In[]:=dcstreets[[1]]<br />
Out[]:=LayerName -&gt; StreetSegmentLn<br />
In[]:=dcstreets[[2]]<br />
Out[]:=Geometry -&gt; <em>long list of graphics primitives defining the data elements</em><br />
In[]:=dcstreets[[3]]<br />
Out[]:=Labels -&gt; <em>list of the names of metadata fields</em><br />
In[]:=dcstreets[[4]]<br />
Out[]:=LabeledData -&gt; <em>list of (long) lists of metadata for each data element</em><br />
</code><br />
For this data file, the data elements are segments of streets between intersections, so the graphics primitives are lines defined by two (or more, for curved streets) points. There are 25 metadata fields, including the name of each street, the address range covered by the segment, the quadrant, and the type of road (e.g. Local, Principal Arterial, etc.). The <code>FullForm</code> of Mathematica replacement rule, such as <code>lhs -&gt; rhs</code>, is <code>Rule[lhs,rhs]</code>, so we access the data in each of the four rules as the second element of another list. Thus we can get at, say, the graphics primitives for the 27th street segment as<br />
<code><br />
In[]:=dcstreets[[2,2,27]]<br />
Out[]:=Line[{{396233., 138045.}, {396233., 138132.}, {396233., 138142.}}]<br />
</code><br />
For ease in working with these data, I combined the geometry and metadata into one table for the 13414 street segments:<br />
<code><br />
dcstreetdata = Transpose[Join[{dcstreets[[2, 2]]}, dcstreets[[4, 2, All, 2]]]];<br />
</code><br />
I separate this into two groups: state-named streets, and the rest:<br />
<code><br />
statestreets = Select[dcstreetdata, MemberQ[ToUpperCase[states], #[[6]]] &amp;];<br />
nonstatestreets = Select[dcstreetdata, ! MemberQ[ToUpperCase[states], #[[6]]] &amp;];<br />
</code><br />
The 6th element of each entry in <code>dcstreetdata</code> is the name of the street. From this, I create two graphics:<br />
<code><br />
nonstatemap = Graphics[{Gray, nonstatestreets[[All, 1]]}]</code></p>
<p><code><br />
statemap = Graphics[Function[x, Tooltip[{Directive[Thick, RGBColor[.5 + 2 (.5 - x[[2]]), 0, .5 + 2 (x[[2]] - .5)]], Transpose[Select[statestreets, Function[y, y[[6]] == x[[1]]]]][[1]]}, x[[1]]]] /@ percentData]<br />
</code><br />
I&#8217;ve packed a lot into statemap, using nested pure functions: it makes a Tooltip with the state/street name popping up upon mouseover (it works better in Mathematica than in the export HTML). For each state from the list of election returns in <code>percentData</code>, it finds all the street segments named after that state and makes a graphic element out of the geometry of that street segment, of a color that ranges from pure blue to pure red. The red-blue divide is stretched so that pure blue corresponds to the percentage of Obama&#8217;s highest percentage (Hawaii, 72.99%) and pure red corresponds to Obama&#8217;s lowest percentage (Wyoming, 33.43%). The final map is created with <code>Show</code>:<br />
<code><br />
votemap = Show[statemap, nonstatemap]</code></p>
<p>So far, so good. I&#8217;ll write more on Mathematica and DC GIS data soon.</p>
<ol class="footnotes"><li id="footnote_0_206" class="footnote">really, it&#8217;s Obama&#8217;s percentage of the combined Obama/ McCain vote, ignoring votes for other candidates</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2009/01/17/red-street-blue-street/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The next Mathematica</title>
		<link>http://metcaffeination.net/weblog/2008/11/22/the-next-mathematica/</link>
		<comments>http://metcaffeination.net/weblog/2008/11/22/the-next-mathematica/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 16:46:07 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[consumer society]]></category>
		<category><![CDATA[doing the math]]></category>
		<category><![CDATA[mathematics]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=181</guid>
		<description><![CDATA[To me, an intermediate and somewhat casual Mathematica user, the news that Mathematica 7 had been released was a surprise. Surprising to me because Mathematica usually goes much longer between major-digit releases; I would have anticipated this to be Version 6.1. For fun, I&#8217;ve plotted the history of Mathematica versions1 :
 
Mathematica 6 was a substantial upgrade: the graphics [...]]]></description>
			<content:encoded><![CDATA[<p>To me, an intermediate and somewhat casual <a href="http://www.wolfram.com/products/mathematica/index.html">Mathematica</a> user, the <a href="http://blog.wolfram.com/2008/11/18/surprise-mathematica-70-released-today/">news that Mathematica 7</a> had been released was a surprise. Surprising to me because Mathematica usually goes much longer between major-digit releases; I would have anticipated this to be Version 6.1. For fun, I&#8217;ve plotted the history of Mathematica versions<sup>1</sup> :</p>
<p> </p>
<div id="attachment_183" class="wp-caption aligncenter" style="width: 410px"><img class="size-full wp-image-183" title="mathematicaversions" src="http://metcaffeination.net/weblog/wp-content/uploads/2008/11/mathematicaversions.jpg" alt="Release dates of versions of Mathematica" width="400" height="406" /><p class="wp-caption-text">Release dates of versions of Mathematica</p></div>
<p>Mathematica 6 was a <a href="http://www.wolfram.com/products/mathematica/newin6/">substantial upgrade</a>: the graphics system was completely overhauled, the curated data, that I&#8217;ve used as the basis for some posts here, was added, and the ability for dynamic interactivity was added with <code>Manipulate</code> and <code>Dynamic</code>. </p>
<p>I am not, of course, a major Mathematica user. In fact, although I&#8217;m a physicist, I haven&#8217;t made tremendously much use of Mathematica for my professional work. This is partly because I tend to deal with relatively small data sets, for which a GUI-based data analysis tool is usually easier to work with than the command-line Mathematica. And I&#8217;d consider myself an advanced user of<a href="http://quansoft.com/"> Pro Fit</a>, the data analysis tool that&#8217;s made all the graphs for all the work I&#8217;ve done since about 1998.</p>
<p>In fact, my Mathematica license is my own personal one. As a graduate student, I bought the <a href="http://www.wolfram.com/products/student/mathforstudents/index.html">Student version</a> of Mathematica, which they <a href="http://www.wolfram.com/products/student/mathforstudents/upgrade.html">allow you to upgrade</a> to a full professional license for only a few hundred dollars, compared to the $2500 list price of a new professional license.</p>
<p>Wolfram really wants its users to buy <a href="https://www.wolfram.com/products/service/">Premier Service</a>, a several hundred dollars per year service which entitles you to all upgrades, major and minor. If you don&#8217;t buy premier service, then you need to pay for all upgrades, even the N.M.X to N.M.X+1 minor bug-fixing upgrades. And without premier service, you&#8217;re not even supposed to install Mathematica on more than one computer. Draconian and greedy, if you ask me, but they can do that, because they&#8217;re Wolfram. And for tech-heavy firms that make heavy use of Mathematica and get millions of dollars worth of value from whatever they compute in Mathematica, it makes sense. But it makes it very difficult to be a casual user.</p>
<p>And even though your existing copy can do everything it could the day you bought it, once the difference between your copy and the current release gets large enough, there is no longer an upgrade path.<span style="text-decoration: line-through;"> I think this is one of the motivations to release this as version 7 and not 6.1: I don&#8217;t recall the precise figure, but Wolfram generally offers an upgrade path only for jumps smaller than 1.5. If this is still the case,</span><sup>2</sup> <span style="text-decoration: line-through;">what this does is cut off anyone who hadn&#8217;t upgraded to version 6.</span> <strong>Update: enough with the conspiracy theories! Wolfram clears up the upgrade policy in the comments.</strong></p>
<p>In my case, with Version 6.0.1, I have a choice of paying $750, and getting a year of Premier Service, or paying $500 for just version 7.0.0 with no service. Out of my own pocket, ouch! But what makes it really enticing, for me, is that Mathematica now reads <a href="http://reference.wolfram.com/mathematica/ref/format/SHP.html">SHP</a> files. These are the Geographic Information System data files, promulgated by <a href="http://www.esri.com/">ESRI</a>, in which vector-valued geographic data is commonly exchanged. In particular, the <a href="http://planning.dc.gov/">DC Office of Planning</a> makes an<a href="http://dcatlas.dcgis.dc.gov/catalog/"> amazingly large collection of DC GIS data</a> available in SHP format. The possibility for quantitative analysis of DC mapping data is very tantalizing.</p>
<p>Of course, Wolfram wouldn&#8217;t release a major number upgrade without <a href="http://www.wolfram.com/products/mathematica/newin7/">hundreds of other new features</a>. As of yet, there isn&#8217;t much substantial written about version 7. I did find some <a href="http://www.walkingrandomly.com/?p=332">notes from a beta-tester</a> and from a <a href="http://tcmtechnologyblog.blogspot.com/2008/11/mathematica-7-is-for-everyone.html">college math teacher</a>. I&#8217;ll probably buy it, even though it would mean delaying <a href="http://www.nikonusa.com/Find-Your-Nikon/Product/Camera-Lenses/2180/AF-S-NIKKOR-50mm-f/1.4G.html">other expensive toys</a> that I want.</p>
<ol class="footnotes"><li id="footnote_0_181" class="footnote">most of the dates come from the <a href="http://www.wolfram.com/news/archive/">Wolfram News Archive</a>, some from the <a href="http://www.wolfram.com/company/scrapbook/">Mathematica scrapbook</a> pages</li><li id="footnote_1_181" class="footnote">I&#8217;ve asked Wolfram, but haven&#8217;t received a reply.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/11/22/the-next-mathematica/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Twenty megawatts in your hands</title>
		<link>http://metcaffeination.net/weblog/2008/11/13/twenty-megawatts-in-your-hands/</link>
		<comments>http://metcaffeination.net/weblog/2008/11/13/twenty-megawatts-in-your-hands/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 04:29:33 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[doing the math]]></category>
		<category><![CDATA[energy]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=177</guid>
		<description><![CDATA[I needed to buy more gasoline for the car today, and I decided to see how long it took to fill the tank. I bought ten and a half gallons of gas, and it took 70 seconds to fill it up. Although filling up a gas tank is something that millions of Americans do every [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to buy more gasoline for the car today, and I decided to see how long it took to fill the tank. I bought ten and a half gallons of gas, and it took 70 seconds to fill it up. Although filling up a gas tank is something that millions of Americans do every day, it&#8217;s really remarkable when you stop and think about the energy transfer going on.</p>
<p>Gasoline has, approximately, <a href="http://www.epa.gov/oms/rfgecon.htm">113,000 BTUs per gallon</a>.<sup>1</sup> One <a href="http://en.wikipedia.org/wiki/BTU">BTU is 1055 Joules</a>. So I transferred 1.25 Billion Joules in those 70 seconds, which is a rate of 17.9 megawatts. When you consider that you spend less than two minutes pumping the same amount of energy you burn in four hours of driving, it&#8217;s not surprising that you end up with such a high power. What&#8217;s more interesting, I think, is to contemplate the rather fundamental limits this puts on plug-in electric cars.</p>
<p>Internal combustion engines, according to Wikipedia, are only about <a href="http://en.wikipedia.org/wiki/Internal_combustion_engine#Energy_Efficiency">20% efficient</a>, which is to say, for every 100 BTUs of thermal energy consumed by the engine, you get 20 BTUs of mechanical energy out. This is, in large part, a consequence of fundamental thermodynamics. Although electric motors can be pretty close to perfectly efficient, a similar thermal-to-electric efficiency hit would be taken at the power plant.</p>
<p>Let&#8217;s consider, then, that we want a similar car to mine, but electric. Instead of 1.25 gigajoules, we need to have 250 megajoules. Battery charging can be <a href="http://www.sandia.gov/pv/docs/PDF/batpapsteve.pdf">pretty efficient</a>, at 90% or so, which means we&#8217;d supply 280 megajoules. If we expect the filling-up time to be comparable to that of gasoline cars&#8211;call it 100 seconds for simplicity&#8211;then we&#8217;d need to supply 2.8 megawatts of power. At 240 Volts, which is the voltage we get in our homes, this would require 11700 amps; if you used 1000 Volts, it would take 2800 amps. Although equipment exists<sup>2</sup> to handle these voltage and current levels, it is an understatement to say that it cannot be handled as casually as gasoline pumps are handled. Nor is it clear that any battery system would actually be able to accept this much power.</p>
<p>A linear relationship exists between the power requirement for filling, and the vehicle range, the vehicle power, and the time for a filling. If you&#8217;re satisfied with half the range of a regular vehicle, for example, you could use half the filling power. Let&#8217;s imagine that you&#8217;d be happy for the filling to take ten times as long as with gasoline, or 1000 seconds, just under 17 minutes. At this level, you&#8217;d need 280 kilowatts of power. If battery charging is 90% efficient, that means 10% of the power is going to be dissipated as heat, which in this case would be 28 kilowatts.</p>
<p>For comparison, a typical energy consumption rate for a home furnace is 100,000 BTU per hour, about 28 BTU per second, or 29.3 kilowatts. Which means that the waste heat dissipated during charging for the example&#8211;of a 1000 second fill for a vehicle with similar range and power as a modest gasoline powered sedan, at 90% charging efficiency&#8211;is as much as the entire output of a home furnace.</p>
<p>No wonder overnight charges are the standard.</p>
<ol class="footnotes"><li id="footnote_0_177" class="footnote">Summer and winter blends have slightly more and less, respectively.</li><li id="footnote_1_177" class="footnote">think about <a href="http://www.powerstream.com/Wire_Size.htm">how large the wires</a> would need to be</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/11/13/twenty-megawatts-in-your-hands/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Dow Jones and Mathematica</title>
		<link>http://metcaffeination.net/weblog/2008/11/01/dow-jones-and-mathematica/</link>
		<comments>http://metcaffeination.net/weblog/2008/11/01/dow-jones-and-mathematica/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 18:59:34 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[doing the math]]></category>
		<category><![CDATA[observations]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=153</guid>
		<description><![CDATA[A recent post by economist-blogger Brad DeLong, which was also picked up Matthew Yglesias, mused upon the clustering of the Dow Jones Industrial Average clustered near values starting with 1. He showed a chart with the years 1971&#8211;1984, and 1996&#8211;2008 circled, when the Dow appeared to fluctuate near 1000 and 10000, respectively. Many commenters quickly [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://delong.typepad.com/sdj/2008/10/do-i-have-to-be.html#comments">A recent post</a> by economist-blogger <a href="http://delong.typepad.com">Brad DeLong</a>, which was also picked up <a href="http://yglesias.thinkprogress.org/archives/2008/10/dow_36000.php">Matthew Yglesias</a>, mused upon the clustering of the <a href="http://finance.yahoo.com/q?s=%5EDJI">Dow Jones Industrial Average</a> clustered near values starting with 1. He showed a chart with the years 1971&#8211;1984, and 1996&#8211;2008 circled, when the Dow appeared to fluctuate near 1000 and 10000, respectively. Many commenters quickly jumped to point out that this was an example of <a href="http://en.wikipedia.org/wiki/Benfords_law">Benford&#8217;s Law</a>, which says, essentially, that if you&#8217;re throwing darts at a logarithmically shaped dartboard, you&#8217;re going to hit &#8220;1&#8243; more often than any other digit. If you pick random values of some phenomenon that is logarithmically distributed, you should get values beginning with &#8220;1&#8243; about 30% of the time, which makes sense if you&#8217;ve ever looked at <a href="http://www.intmath.com/downloads/Log-log.pdf">log scale graph paper</a>.</p>
<p>It occurred to me that this is an easy thing to investigate with Mathematica, much like my<a href="http://metcaffeination.net/weblog/2008/10/01/bailout-and-mathematica/"> earlier post on the Bailout</a>. <a href="http://www.wolfram.com/products/mathematica/index.html">Mathematica 6</a> includes access to a huge library of curated data, including historical values of the Dow Jones Industrial average and other indices (and individual stocks, and so forth). The function here is <code>FinancialData</code><span style="font-family: 'Lucida Grande';">, which Wolfram cautions is experimental: I believe they get the data from the same source as, say, <a href="http://finance.yahoo.com/">Yahoo! Finance</a>, and just do the conversions to make it automatically importable into Mathematica. That is, it is no more reliable than other web-based archives. The computations are absurdly easy, taking only a few lines of Mathematica code. </span></p>
<p>The graph I (eventually) produced shows the relative frequencies of first digits that are calculated by Benford&#8217;s Law, together with the relative frequencies of the leading digits from the Dow Jones Industrial Average, the <a href="http://finance.yahoo.com/q?s=%5EGSPC">S&amp;P 500</a>, the <a href="http://finance.yahoo.com/q?s=%5EIXIC">NASDAQ Composite</a> index, the <a href="http://finance.yahoo.com/q?s=%5EGDAXI">DAX 30</a>, and the <a href="http://finance.yahoo.com/q?s=%5EN225">Nikkei 225</a>:</p>
<p><img class="aligncenter size-full wp-image-156" title="Initial digits updated" src="http://metcaffeination.net/weblog/wp-content/uploads/2008/11/benford1.jpg" alt="" width="400" height="247" /><br />
<span id="more-153"></span>It appears that, for both the Dow and the S&amp;P 500, there is a surplus of 1s as leading digits, and also of 8s and 9s. None of the indices particularly follows Benford&#8217;s Law, although I&#8217;ll leave it to the more statistically inclined to figure out the significance of the variations. </p>
<p>To fetch the historical closing prices, simply tell <code>FinancialData</code> what date range you wish to look at; in this case, it was All:<br />
<code><br />
dowJonesData = FinancialData["^DJI",All];<br />
</code><br />
Use the semicolon to prevent a 20000 element list from being displayed. (Actually, Mathematica 6 is smart enough to know that one usually doesn&#8217;t want to look at lists that long, and would show a shortened version. <code>FinancialData</code> uses the standard ticker symbols for the indices: <code>^GSPC</code> for the S&amp;P 500, <code>^IXIC</code> for NASDAQ Composite, <code>^GDAXI</code> for the DAX 30, and <code>^N225</code> for the Nikkei 225. The function returns a list of date-closing value pairs, such as:<br />
<code><br />
In[]:= dowJonesData[[1]]<br />
Out[]:= {{1928, 10, 1}, 240.01}<br />
</code><br />
I wrote a small function that captures the first digit:<br />
<code><br />
FirstDigit[x_] := RealDigits[x][[1, 1]]<br />
</code><br />
<code>RealDigits</code> returns two things: a list of the digits, and the number of digits to the left of the decimal point, so the <code>[[1,1]]</code> element specifier picks out the first element, i.e. the first digit, from the list of digits.<br />
<code><br />
dowJonesDigits = FirstDigit /@ Transpose[dowJonesData][[2]]<br />
</code><br />
Since <code>dowJonesData</code> is a list of date/value pairs, <code>Transpose</code> transforms it into lists of dates and values, and the second of those is what we need to work with. The shorthand for <code>Map</code> is <code>/@</code>, which performs the function on the left, <code>FirstDigit</code>, on each element of the list on the right. To tally the number of each leading digit, I use <code>BinCounts</code>:<br />
<code><br />
dowJonesDigits=Rest[BinCounts[dowJonesDigits]]<br />
dowJonesDigitFractions=N[dowJonesDigits/Length[dowJonesData]]<br />
</code><br />
Since there are no zeroes as leading digits, but <code>BinCounts</code> starts its tally with zero, I use <code>Rest</code> to remove the first element of the returned list. The <code>N</code> is necessary to avoid getting a bunch of (exact) fractions when computing the percentages.</p>
<p>I won&#8217;t go into detail about the production of the graph (or the table): this is the type of thing that often trips me up in Mathematica. Although it is true the Mathematica has nearly unlimited flexibility to make graphs, finding the right method to do something that isn&#8217;t one of the default options often leads to a frustrating cycle of tweaking, looking at the examples, and experimentation. In this case, getting the legend to come out right was a sticking point.</p>
<p>The same is true with the following table, which I present for anyone wishing to think about the data in more detail. Figuring out the right way to make the number of decimals right for each entry took much longer than it should have.</p>
<p>In any case, here are the individual percentages presented in the graph above, along with the total number of data points for each sample set, and the first day for which <code>FinancialData</code> data is available.</p>
<table border="0">
<tbody>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span>Index</span></td>
<td style="text-align: center;"><span>Benford</span></td>
<td style="text-align: center;"><span>Dow Jones</span></td>
<td style="text-align: center;"><span>S&amp;P 500</span></td>
<td style="text-align: center;"><span>NASDAQ</span></td>
<td style="text-align: center;"><span>DAX 30</span></td>
<td style="text-align: center;"><span>Nikkei 225</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span>Start</span></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"><span>Oct 1,1928</span></td>
<td style="text-align: center;"><span>01/03/50</span></td>
<td style="text-align: center;"><span>02/05/71</span></td>
<td style="text-align: center;"><span>11/26/90</span></td>
<td style="text-align: center;"><span>01/04/84</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span>#</span></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"><span>20124</span></td>
<td style="text-align: center;"><span>14817</span></td>
<td style="text-align: center;"><span>9536</span></td>
<td style="text-align: center;"><span>4539</span></td>
<td style="text-align: center;"><span>6123</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>1</span></span></span></span></td>
<td style="text-align: center;"><span>30.1</span></td>
<td style="text-align: center;"><span>35.42</span></td>
<td style="text-align: center;"><span>36.3</span></td>
<td style="text-align: center;"><span>36.71</span></td>
<td style="text-align: center;"><span>16.59</span></td>
<td style="text-align: center;"><span>65.31</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>2</span></span></span></span></td>
<td style="text-align: center;"><span>17.61</span></td>
<td style="text-align: center;"><span>12.65</span></td>
<td style="text-align: center;"><span>11.24</span></td>
<td style="text-align: center;"><span>23.7</span></td>
<td style="text-align: center;"><span>19.78</span></td>
<td style="text-align: center;"><span>22.85</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>3</span></span></span></span></td>
<td style="text-align: center;"><span>12.49</span></td>
<td style="text-align: center;"><span>6.39</span></td>
<td style="text-align: center;"><span>6.93</span></td>
<td style="text-align: center;"><span>10.58</span></td>
<td style="text-align: center;"><span>11.99</span></td>
<td style="text-align: center;"><span>6.11</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>4</span></span></span></span></td>
<td style="text-align: center;"><span>9.69</span></td>
<td style="text-align: center;"><span>4.78</span></td>
<td style="text-align: center;"><span>11.</span></td>
<td style="text-align: center;"><span>8.15</span></td>
<td style="text-align: center;"><span>16.13</span></td>
<td style="text-align: center;"><span>0</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>5</span></span></span></span></td>
<td style="text-align: center;"><span>7.92</span></td>
<td style="text-align: center;"><span>3.72</span></td>
<td style="text-align: center;"><span>5.8</span></td>
<td style="text-align: center;"><span>3.24</span></td>
<td style="text-align: center;"><span>15.71</span></td>
<td style="text-align: center;"><span>0</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>6</span></span></span></span></td>
<td style="text-align: center;"><span>6.69</span></td>
<td style="text-align: center;"><span>5.5</span></td>
<td style="text-align: center;"><span>4.75</span></td>
<td style="text-align: center;"><span>3.16</span></td>
<td style="text-align: center;"><span>11.35</span></td>
<td style="text-align: center;"><span>0</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>7</span></span></span></span></td>
<td style="text-align: center;"><span>5.8</span></td>
<td style="text-align: center;"><span>5.99</span></td>
<td style="text-align: center;"><span>4.22</span></td>
<td style="text-align: center;"><span>6.66</span></td>
<td style="text-align: center;"><span>7.91</span></td>
<td style="text-align: center;"><span>0.42</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>8</span></span></span></span></td>
<td style="text-align: center;"><span>5.12</span></td>
<td style="text-align: center;"><span>13.78</span></td>
<td style="text-align: center;"><span>7.96</span></td>
<td style="text-align: center;"><span>3.18</span></td>
<td style="text-align: center;"><span>0.55</span></td>
<td style="text-align: center;"><span>2.61</span></td>
</tr>
<tr style="vertical-align:bottom;">
<td style="text-align: center;"><span><span class="TextInline"><span class="TRInline"><span>9</span></span></span></span></td>
<td style="text-align: center;"><span>4.58</span></td>
<td style="text-align: center;"><span>11.78</span></td>
<td style="text-align: center;"><span>11.8</span></td>
<td style="text-align: center;"><span>4.62</span></td>
<td style="text-align: center;"><span>0</span></td>
<td style="text-align: center;"><span>2.69</span></td>
</tr>
</tbody>
</table>
<p> <strong>Update, 20 Nov 2008</strong>: fixed Nikkei column in table.</p>
]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/11/01/dow-jones-and-mathematica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bailout and Mathematica</title>
		<link>http://metcaffeination.net/weblog/2008/10/01/bailout-and-mathematica/</link>
		<comments>http://metcaffeination.net/weblog/2008/10/01/bailout-and-mathematica/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 03:41:38 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[consumer society]]></category>
		<category><![CDATA[doing the math]]></category>
		<category><![CDATA[politics]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=134</guid>
		<description><![CDATA[A friend of mine (and regular commenter here) has pointed out that, even if the $700,000,000,000 bailout passes, and adds to our National Debt, we&#8217;d still have a Debt-to-GDP ratio that was less than Germany&#8217;s.1 Wikipedia says that the US National Debt is 60.8% of our GDP, that Germany&#8217;s is 63.1%, and that our GDP [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine (and regular commenter here) has pointed out that, even if the $700,000,000,000 bailout passes, and adds to our National Debt, we&#8217;d still have a <a href="http://en.wikipedia.org/wiki/List_of_countries_by_public_debt">Debt-to-GDP ratio</a> that was less than Germany&#8217;s.<sup>1</sup> Wikipedia says that the US National Debt is 60.8% of our GDP, that Germany&#8217;s is 63.1%, and that our GDP is $13.8 trillion. Well, add $700 billion to 60.8% of $13.8 trillion and the new figure is 65.8%&#8211;pretty close; there are different ways of measuring both GDP and the Debt.</p>
<p>But I realized that this sort of comparison is something that <a href="http://www.wolfram.com/products/mathematica/index.html">Mathematica 6</a> is supposed to be good at.  Mathematica is an amazingly powerful system for doing mathematics on a computer. Its strength, traditionally, has been symbolic manipulation&#8211;I most often use it for the <a href="http://integrals.wolfram.com/index.jsp">Integrate</a> command, which can do most of the integrals that in grad school I&#8217;d look up in <a href="http://www.mathtable.com/gr/">Gradshteyn and Ryzhik</a>. Version 6 has added, <a href="http://www.wolfram.com/products/mathematica/newin6/">amongst other things</a>, a<a href="http://www.wolfram.com/products/mathematica/newin6/content/LoadOnDemandCuratedData/"> huge library of curated data</a>, loaded over the Internet, that&#8217;s relatively straightforward to use.</p>
<p>The command <a href="http://reference.wolfram.com/mathematica/ref/CountryData.html">CountryData</a> gives access to all sorts of country-by-country information, including &#8220;GDP&#8221; and &#8220;GovernmentDebt&#8221;. So following one of the examples in the documentation, I produced this graph, plotting the Debt-to-GDP ratio versus GDP for (nearly) all the countries for which Mathematica has data. (Note that the x-axis is a logarithmic scale.) The United States, before and after a $700 billion bailout, are shown in green and red, respectively. </p>
<p>If the xhtml export actually works the way it&#8217;s supposed to, you should be able to hover your mouse cursor over each point and have a little ToolTip pop up telling you which country the data are for.</p>
<table class='Output'>
<tr style='vertical-align:middle;'>
<td style='text-align: center;'><span><img src='http://metcaffeination.net/weblog/wp-content/uploads/2008/10/debtgdpxhtml_1.gif' alt='"debtgdp.xhtml_1.gif"' width='400' height='262' style='vertical-align:middle' usemap='#map_1'/></p>
<map name='map_1'>
<area shape='rect' coords='374,172,378,168' title='Bailed Out United States' />
<area shape='rect' coords='374,178,378,174' title='Present United States' />
<area shape='rect' coords='41,91,45,87' title='Zimbabwe' />
<area shape='rect' coords='109,193,113,189' title='Zambia' />
<area shape='rect' coords='128,214,132,210' title='Yemen' />
<area shape='rect' coords='171,197,175,193' title='Vietnam' />
<area shape='rect' coords='213,219,217,215' title='Venezuela' />
<area shape='rect' coords='123,216,127,212' title='Uzbekistan' />
<area shape='rect' coords='130,166,134,162' title='Uruguay' />
<area shape='rect' coords='374,178,378,174' title='United States' />
<area shape='rect' coords='309,202,313,198' title='United Kingdom' />
<area shape='rect' coords='214,233,218,229' title='United Arab Emirates' />
<area shape='rect' coords='194,232,198,228' title='Ukraine' />
<area shape='rect' coords='107,183,111,179' title='Uganda' />
<area shape='rect' coords='242,176,246,172' title='Turkey' />
<area shape='rect' coords='147,183,151,179' title='Tunisia' />
<area shape='rect' coords='128,207,132,203' title='Trinidad and Tobago' />
<area shape='rect' coords='218,201,222,197' title='Thailand' />
<area shape='rect' coords='115,174,119,170' title='Tanzania' />
<area shape='rect' coords='235,209,239,205' title='Taiwan' />
<area shape='rect' coords='148,210,152,206' title='Syria' />
<area shape='rect' coords='241,189,245,185' title='Switzerland' />
<area shape='rect' coords='241,194,245,190' title='Sweden' />
<area shape='rect' coords='152,162,156,158' title='Sudan' />
<area shape='rect' coords='143,155,147,151' title='Sri Lanka' />
<area shape='rect' coords='285,202,289,198' title='Spain' />
<area shape='rect' coords='272,227,276,223' title='South Korea' />
<area shape='rect' coords='225,208,229,204' title='South Africa' />
<area shape='rect' coords='154,217,158,213' title='Slovenia' />
<area shape='rect' coords='169,212,173,208' title='Slovakia' />
<area shape='rect' coords='202,144,206,140' title='Singapore' />
<area shape='rect' coords='7,59,11,55' title='Seychelles' />
<area shape='rect' coords='153,206,157,202' title='Serbia' />
<area shape='rect' coords='103,200,107,196' title='Senegal' />
<area shape='rect' coords='240,204,244,200' title='Saudi Arabia' />
<area shape='rect' coords='277,236,281,232' title='Russia' />
<area shape='rect' coords='199,229,203,225' title='Romania' />
<area shape='rect' coords='167,215,171,211' title='Qatar' />
<area shape='rect' coords='216,178,220,174' title='Portugal' />
<area shape='rect' coords='236,200,240,196' title='Poland' />
<area shape='rect' coords='197,178,201,174' title='Philippines' />
<area shape='rect' coords='187,210,191,206' title='Peru' />
<area shape='rect' coords='102,213,106,209' title='Paraguay' />
<area shape='rect' coords='87,205,91,201' title='Papua New Guinea' />
<area shape='rect' coords='125,181,129,177' title='Panama' />
<area shape='rect' coords='206,201,210,197' title='Pakistan' />
<area shape='rect' coords='153,240,157,236' title='Oman' />
<area shape='rect' coords='236,197,240,193' title='Norway' />
<area shape='rect' coords='202,237,206,233' title='Nigeria' />
<area shape='rect' coords='82,161,86,157' title='Nicaragua' />
<area shape='rect' coords='194,222,198,218' title='New Zealand' />
<area shape='rect' coords='262,191,266,187' title='Netherlands' />
<area shape='rect' coords='88,211,92,207' title='Namibia' />
<area shape='rect' coords='94,225,98,221' title='Mozambique' />
<area shape='rect' coords='175,183,179,179' title='Morocco' />
<area shape='rect' coords='65,168,69,164' title='Moldova' />
<area shape='rect' coords='270,229,274,225' title='Mexico' />
<area shape='rect' coords='89,172,93,168' title='Mauritius' />
<area shape='rect' coords='206,201,210,197' title='Malaysia' />
<area shape='rect' coords='49,32,53,28' title='Malawi' />
<area shape='rect' coords='88,213,92,209' title='Macedonia' />
<area shape='rect' coords='146,229,150,225' title='Lithuania' />
<area shape='rect' coords='166,240,170,236' title='Libya' />
<area shape='rect' coords='135,50,139,46' title='Lebanon' />
<area shape='rect' coords='131,238,135,234' title='Latvia' />
<area shape='rect' coords='192,237,196,233' title='Kuwait' />
<area shape='rect' coords='138,201,142,197' title='Kenya' />
<area shape='rect' coords='182,239,186,235' title='Kazakhstan' />
<area shape='rect' coords='119,168,123,164' title='Jordan' />
<area shape='rect' coords='333,62,337,58' title='Japan' />
<area shape='rect' coords='107,104,111,100' title='Jamaica' />
<area shape='rect' coords='127,179,131,175' title='Ivory Coast' />
<area shape='rect' coords='300,129,304,125' title='Italy' />
<area shape='rect' coords='204,142,208,138' title='Israel' />
<area shape='rect' coords='220,219,224,215' title='Ireland' />
<area shape='rect' coords='224,218,228,214' title='Iran' />
<area shape='rect' coords='240,203,244,199' title='Indonesia' />
<area shape='rect' coords='273,193,277,189' title='India' />
<area shape='rect' coords='122,211,126,207' title='Iceland' />
<area shape='rect' coords='196,182,200,178' title='Hungary' />
<area shape='rect' coords='215,246,219,242' title='Hong Kong' />
<area shape='rect' coords='103,177,107,173' title='Honduras' />
<area shape='rect' coords='147,216,151,212' title='Guatemala' />
<area shape='rect' coords='233,158,237,154' title='Greece' />
<area shape='rect' coords='113,174,117,170' title='Ghana' />
<area shape='rect' coords='317,173,321,169' title='Germany' />
<area shape='rect' coords='104,215,108,211' title='Gabon' />
<area shape='rect' coords='307,175,311,171' title='France' />
<area shape='rect' coords='219,206,223,202' title='Finland' />
<area shape='rect' coords='116,162,120,158' title='Ethiopia' />
<area shape='rect' coords='123,243,127,239' title='Estonia' />
<area shape='rect' coords='104,243,108,239' title='Equatorial Guinea' />
<area shape='rect' coords='128,198,132,194' title='El Salvador' />
<area shape='rect' coords='195,137,199,133' title='Egypt' />
<area shape='rect' coords='158,210,162,206' title='Ecuador' />
<area shape='rect' coords='148,200,152,196' title='Dominican Republic' />
<area shape='rect' coords='229,208,233,204' title='Denmark' />
<area shape='rect' coords='204,222,208,218' title='Czech Republic' />
<area shape='rect' coords='128,174,132,170' title='Cyprus' />
<area shape='rect' coords='159,198,163,194' title='Croatia' />
<area shape='rect' coords='135,189,139,185' title='Costa Rica' />
<area shape='rect' coords='201,195,205,191' title='Colombia' />
<area shape='rect' coords='314,227,318,223' title='China' />
<area shape='rect' coords='205,241,209,237' title='Chile' />
<area shape='rect' coords='286,177,290,173' title='Canada' />
<area shape='rect' coords='128,179,132,175' title='Cameroon' />
<area shape='rect' coords='147,216,151,212' title='Bulgaria' />
<area shape='rect' coords='280,203,284,199' title='Brazil' />
<area shape='rect' coords='101,240,105,236' title='Botswana' />
<area shape='rect' coords='110,221,114,217' title='Bosnia and Herzegovina' />
<area shape='rect' coords='16,155,20,151' title='Bhutan' />
<area shape='rect' coords='242,146,246,142' title='Belgium' />
<area shape='rect' coords='177,200,181,196' title='Bangladesh' />
<area shape='rect' coords='123,216,127,212' title='Bahrain' />
<area shape='rect' coords='131,239,135,235' title='Azerbaijan' />
<area shape='rect' coords='235,177,239,173' title='Austria' />
<area shape='rect' coords='268,231,272,227' title='Australia' />
<area shape='rect' coords='52,197,56,193' title='Aruba' />
<area shape='rect' coords='220,177,224,173' title='Argentina' />
<area shape='rect' coords='163,221,167,217' title='Angola' />
<area shape='rect' coords='197,217,201,213' title='Algeria' />
<area shape='rect' coords='167,215,171,211' title='Qatar' />
<area shape='rect' coords='202,237,206,233' title='Nigeria' />
<area shape='rect' coords='262,191,266,187' title='Netherlands' />
<area shape='rect' coords='88,211,92,207' title='Namibia' />
<area shape='rect' coords='65,168,69,164' title='Moldova' />
<area shape='rect' coords='270,229,274,225' title='Mexico' />
<area shape='rect' coords='89,172,93,168' title='Mauritius' />
<area shape='rect' coords='88,213,92,209' title='Macedonia' />
<area shape='rect' coords='146,229,150,225' title='Lithuania' />
<area shape='rect' coords='166,240,170,236' title='Libya' />
<area shape='rect' coords='192,237,196,233' title='Kuwait' />
<area shape='rect' coords='220,219,224,215' title='Ireland' />
<area shape='rect' coords='147,216,151,212' title='Guatemala' />
<area shape='rect' coords='233,158,237,154' title='Greece' />
<area shape='rect' coords='104,215,108,211' title='Gabon' />
<area shape='rect' coords='148,200,152,196' title='Dominican Republic' />
<area shape='rect' coords='229,208,233,204' title='Denmark' />
<area shape='rect' coords='201,195,205,191' title='Colombia' />
<area shape='rect' coords='147,216,151,212' title='Bulgaria' />
<area shape='rect' coords='16,155,20,151' title='Bhutan' />
<area shape='rect' coords='242,146,246,142' title='Belgium' />
<area shape='rect' coords='220,177,224,173' title='Argentina' />
<area shape='rect' coords='163,221,167,217' title='Angola' />
<area shape='rect' coords='197,217,201,213' title='Algeria' />
</map>
<p></span></td>
</tr>
<tr style='vertical-align:middle;'>
<td style='text-align: center;'><span><span class="TextInline"><span class="TRInline"><span>GDP [$US]</span></span></span></span></td>
</tr>
</table>
<p>Mathematica has a syntax that strikes many as arcane. Since I learned about computers with <a href="http://en.wikipedia.org/wiki/Procedural_programming">procedural programming</a>, and haven&#8217;t really done any <a href="http://en.wikipedia.org/wiki/Functional_programming">functional programming</a>, I too struggle to get Mathematica to do what I want it to do. But one can often do complicated things, such as the above graph, with a very compact command. To make the main graph&#8211;the red and green dots are relatively trivial additions&#8211;the command I used is:<br />
<span id="more-134"></span><br />
<code><br />
gdpplot =<br />
 ListLogLinearPlot[<br />
  Tooltip[{CountryData[#, "GDP"],<br />
      CountryData[#, "GovernmentDebt"]/CountryData[#, "GDP"]},<br />
     CountryData[#, "Name"]] &#038; /@ CountryData["Countries"],<br />
  PlotRange -> {{10^9, 2 10^13}, {0, 2}}]<br />
</code></p>
<p>There are a couple things one needs to understand for this to make sense: First is Mathematica&#8217;s syntax for <a href="http://reference.wolfram.com/mathematica/tutorial/PureFunctions.html">pure functions</a>, using all the stuff with the #s and up through the &#038;. Second, the /@ is shorthand for the <a href="http://reference.wolfram.com/mathematica/ref/Map.html">Map</a> command, which means apply the function on the left to each element of the list on the right. Finally, the command <code>CountryData["Countries"]</code> produces a list of all the countries for which Mathematica has data. </p>
<ol class="footnotes"><li id="footnote_0_134" class="footnote">He is, nevertheless, against the bailout.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/10/01/bailout-and-mathematica/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Iced tea</title>
		<link>http://metcaffeination.net/weblog/2008/07/02/iced-tea/</link>
		<comments>http://metcaffeination.net/weblog/2008/07/02/iced-tea/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 03:32:53 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[doing the math]]></category>
		<category><![CDATA[food]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=102</guid>
		<description><![CDATA[I like to make iced tea during the summer months. Not that vile powdered stuff, but real tea or herbal infusions. To make it quickly&#8211;so one doesn&#8217;t have to wait for near-boiling tea to cool all the way down to an icy-cold temperature, I prefer to brew double-strength tea and pour it over ice, such [...]]]></description>
			<content:encoded><![CDATA[<p>I like to make iced tea during the summer months. Not that vile powdered stuff, but real tea or herbal infusions. To make it quickly&#8211;so one doesn&#8217;t have to wait for near-boiling tea to cool all the way down to an icy-cold temperature, I prefer to brew double-strength tea and pour it over ice, such that most of the ice melts, and the near-boiling tea cools, together making an appropriately strong chilled drink.</p>
<p>How much ice does one need? Well, to cool 1 gram of boiling water down to the freezing point, 100 calories<sup>1</sup> have to be extracted from it. <a href="http://en.wikipedia.org/wiki/Heat_of_fusion">Melting 1 gram of ice takes about 80 calories</a> of heat. So a mixture of 56% (by weight) ice and 44% boiling tea will melt all the ice and leave the final mixture at 32°F.</p>
<p>How do you measure this amount of ice? Well, you could weigh it, but that&#8217;s not always convenient. Here&#8217;s a bit of mathematics to justify a simple approximation: The density of ice is approximately 92% that of liquid water. If you fill a container with ice cubes&#8211;or with any solid particles, for that matter&#8211;there is a fair amount of air space between the grains. If ice cubes were spherical, then only about 64% of the volume would be ice, and the rest air&#8211;this is known as the <a href="http://en.wikipedia.org/wiki/Random_close_pack">random close-packed fraction</a>. Ice cubes aren&#8217;t spheres, but the fraction should be roughly the same. Which means that if you fill a container up with ice cubes, they would melt to a volume about 59% of that of the container. If you add 50% of the volume of the container of boiling water, the ice would represent about 54% of the total mass of water and ice, and mixing the two together you&#8217;d end up with a volume of liquid equal to 109% the volume of the container, at 32°F. To avoid overflow, you&#8217;d need to use slightly less ice and boiling water.</p>
<p>So, my iced-tea algorithm:</p>
<p> </p>
<ol>
<li>Fill a container most of the way up with ice cubes</li>
<li>Measure out as much tea as you need for the full volume of the container</li>
<li>Brew the tea using a volume of water that&#8217;s slightly less than half that of the volume of the container</li>
<li>Pour the brewed double-strength tea (through a strainer, if necessary) into the ice-filled container</li>
<li>Stir to cool the tea and melt the ice; most of the ice will melt. Since the brewed tea will have cooled off a bit while steeping, it won&#8217;t have enough heat to melt all the ice and so there will still be some ice left.</li>
</ol>
<p> </p>
<p>The tea leaves will absorb some of the water, and many containers hold (slightly) more than their nominal volume, so using (say) exactly 1 quart of water to make tea in a 2-quart container shouldn&#8217;t present any problems.</p>
<p>To brew, I&#8217;ve adopted the Cook&#8217;s Illustrated technique of mixing the tea and cold water in a saucepan, heating over medium heat to 190°F, then shutting off the heat to let steep for 3 or so more minutes: all total, the brewing should take about 15 minutes.</p>
<p>I&#8217;m fond of a mint infusion: for a 2 quart container, use 2 Tablespoons dried mint. I also like minted iced tea, for which I use a mixture of 4 teaspoons loose tea plus 3 teaspoons mint for a 2 quart container.</p>
<ol class="footnotes"><li id="footnote_0_102" class="footnote"><a href="http://en.wikipedia.org/wiki/Calorie">Thermodynamic calories</a>, not food Calories. A food Calories, spelled with a capital C, is 1000 thermodynamic calories.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/07/02/iced-tea/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Paul Sally.</title>
		<link>http://metcaffeination.net/weblog/2008/05/29/paul-sally/</link>
		<comments>http://metcaffeination.net/weblog/2008/05/29/paul-sally/#comments</comments>
		<pubDate>Fri, 30 May 2008 03:33:42 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[doing the math]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[mathematics]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=87</guid>
		<description><![CDATA[The recent issue of the alumni magazine from my undergraduate alma mater, The University of Chicago, includes a profile of mathematician Paul Sally, who taught the Honors Analysis in Rn sequence I took in my second year. 
Despite the rigorously intellectual image of itself that the University promotes, the alumni magazine is usually as circumspect as an in-flight [...]]]></description>
			<content:encoded><![CDATA[<p>The recent issue of <a href="http://magazine.uchicago.edu">the alumni magazine</a> from my undergraduate alma mater, <a href="http://uchicago.edu">The University of Chicago</a>, includes <a href="http://magazine.uchicago.edu/0856/features/sally.shtml"><span>a profile of mathematician Paul Sally</span></a>, who taught the Honors Analysis in <strong>R</strong><sup>n</sup> sequence I took in my second year. </p>
<p>Despite the rigorously intellectual image of itself that the University promotes, the alumni magazine is usually as circumspect as an in-flight magazine. Of course the primary purpose of the magazine is to cultivate us as donors, so on-campus controversy, intellectual or otherwise, gets scant attention. The article on Sally certainly follows the magazine&#8217;s formula of uncritical boosterism, but I still found it a delight to read: it took me back to what was probably the most intellectually fulfilling experience of my academic career, a time when all the promotional slogans about the life of the mind were very real for me.</p>
<p>Although my enthusiasm for working in a lab led me to choose physics over mathematics, I still have a fondness for pure mathematics. I retain a handful of habits  that are more a part of math culture than physics culture.<sup>1</sup> Sally&#8217;s course kept me on the fence between the two disciplines.</p>
<p>Sally delivered his classes entirely without notes, and the course rarely made reference to the assigned book (<a href="http://store.doverpublications.com/0486612260.html">a cheap Dover reprint</a> and <a href="http://www.perseusbooksgroup.com/westview/book_detail.jsp?isbn=0805390219">a small volume from Spivak</a>). He led a &#8220;discussion session,&#8221; Tuesday evenings from 6:30 until 8 or 9, stretching the amount of class time. He told us he expected at least 25 hours per week from us, at one point advising us to make posters which read &#8220;Mathematics&#8230; is a full time job.&#8221; It was mathematics by immersion.</p>
<p>Not every teacher can pull this off so successfully: it&#8217;s easy enough to assign lots and lots of work, but the combination of a heavy workload and an uninspiring instructor usually results in lots of incomplete assignments. </p>
<p>Sally once remarked that, as you continue in mathematics, you get to a point where hard work is not only necessary, but also sufficient, to prove theorems and make progress. He was getting us to develop the sort of attitude and work ethic to reach that point.</p>
<p>There are many things I learned in college that I&#8217;ve now forgotten, many problems I can no longer solve. I don&#8217;t know how much review it would take for me to be able to solve the problems from Honors Analysis again, but, 15 years on, I feel I still have a well-developed understanding of the structure of the real numbers. </p>
<p>Here&#8217;s <a href="http://http//chronicle.uchicago.edu/950525/sally.shtml"><span>another article</span></a> about Sally, for winning a teaching award.</p>
<ol class="footnotes"><li id="footnote_0_87" class="footnote"> In particular, I can&#8217;t stand the common-in-physics habit of using the word &#8220;finite&#8221; when what is really meant is &#8220;non-zero&#8221; or &#8220;infinitesimal.&#8221; </li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/05/29/paul-sally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scale in the media</title>
		<link>http://metcaffeination.net/weblog/2008/04/25/scale-in-the-media/</link>
		<comments>http://metcaffeination.net/weblog/2008/04/25/scale-in-the-media/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 03:10:57 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[Sierra Club radio]]></category>
		<category><![CDATA[consumer society]]></category>
		<category><![CDATA[doing the math]]></category>
		<category><![CDATA[energy]]></category>
		<category><![CDATA[environment]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=74</guid>
		<description><![CDATA[I lamented in an earlier post that questions of scale are all too often left out of discussions of environmental solutions. To recent pieces that bring the issue up:
Michael Pollan&#8217;s Why Bother?, from last Sunday&#8217;s New York Times Magazine, opens by recounting what for Pollan was the &#8220;most upsetting moment&#8221; of An Inconvenient Truth: the [...]]]></description>
			<content:encoded><![CDATA[<p>I lamented <a href="http://metcaffeination.net/weblog/2008/04/03/the-scale-of-green-solutions/">in an earlier post</a> that questions of scale are all too often left out of discussions of environmental solutions. To recent pieces that bring the issue up:</p>
<p>Michael Pollan&#8217;s <a href="http://www.nytimes.com/2008/04/20/magazine/20wwln-lede-t.html?pagewanted=1&amp;_r=2">Why Bother?</a>, from last Sunday&#8217;s New York Times Magazine, opens by recounting what for Pollan was the &#8220;most upsetting moment&#8221; of <a href="http://www.climatecrisis.net/">An Inconvenient Truth</a>: the &#8220;immense disproportion between the magnitude of the problem Gore had described and the puniness of what he was asking us to do about it.&#8221; Pollan defends notions of virtue and the steps, particularly gardening, that individuals might take to reduce their individual carbon footprints, vis-à-vis other responses to the climate crisis such as hopingfor some future technology. He writes: &#8220;Cheap energy, which gives us climate change, fosters precisely the mentality that makes dealing with climate change in our own lives seem impossibly difficult&#8230;. Al Gore asks us to change the light bulbs because he probably can’t imagine us doing anything much more challenging, like, say, growing some portion of our own food.&#8221;</p>
<p>Second, the <a href="http://sierraclub.typepad.com/sierra_club_radio/2008/04/s.html">April 12th Sierra Club Radio podcast</a> has a segment with Bob Schildgen&#8212;<a href="http://sierraclub.typepad.com/mrgreen/">Mr. Green</a>&#8212;promoting his new book, which compiles questions and answers from his column in Sierra magazine. On the question of paper vs plastic (his answer&#8211;neither; bring your own bag), he encourages listeners to put things into perspective by mentioning that you likely burn as much petroleum in one trip to the grocery store as it takes to make all the plastic bags you&#8217;d use in a whole year. I can&#8217;t find his numbers online, but using the figures <a href="http://metcaffeination.net/weblog/2007/11/16/plastic-bags/">I wrote about earlier</a>: 330 bags per American per year, 200 bags per gallon, so just over one and a half gallons of oil per American devoted to plastic bags. At 20 miles per gallon, you could make a round trip to a supermarket 15 miles away. Right order of magnitude, but I think you could travel a bit farther on that amount of gas.</p>
<p>This exercise in scale is then thrown out the window later in the interview, when host Orli Cotel asks the heavily loaded question: &#8220;For our listners who do own cars or need cars for whatever reason, what tips can you give us, as Mr. Green, to help reduce the amount of gas that we&#8217;re using,  besides of course cutting back on car travel?&#8221; (As if there&#8217;s some secret, magic way to drive without using gas that only the hardcore enviros know about.) Mr. Green goes on to mention that Americans lose about 4 million gallons of gasoline per day because of underinflated tires. Of course, he doesn&#8217;t put this into perspective: that&#8217;s about 1% of our daily gasoline consumption; we burn through 4 million gallons of gasoline in about 15 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/04/25/scale-in-the-media/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>March Madness wrap-up</title>
		<link>http://metcaffeination.net/weblog/2008/04/08/march-madness-wrap-up/</link>
		<comments>http://metcaffeination.net/weblog/2008/04/08/march-madness-wrap-up/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 02:27:08 +0000</pubDate>
		<dc:creator>thm</dc:creator>
				<category><![CDATA[doing the math]]></category>
		<category><![CDATA[sport]]></category>

		<guid isPermaLink="false">http://metcaffeination.net/weblog/?p=72</guid>
		<description><![CDATA[Well, I didn&#8217;t place in the top two of the March Madness pool I entered this year, but both my brackets did manage to beat all my other family members&#8217; brackets. As I wrote in my previous entry, I also filled out a third bracket, based entirely on a sophisticated ratings scheme. I entered this [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I didn&#8217;t place in the top two of the March Madness pool I entered this year, but both my brackets did manage to beat all my other family members&#8217; brackets. As I wrote in <a href="http://metcaffeination.net/weblog/2008/03/20/my-march-madness/">my previous entry</a>, I also filled out a third bracket, based entirely on a <a href="http://kenpom.com/stats.php">sophisticated ratings scheme</a>. I entered <a href="http://projects.washingtonpost.com/ncaa/madness/bracket/view/?2747">this bracket</a> in the <a href="http://games.espn.go.com/tcmen/entry?entryID=3651043">ESPN</a> and<a href="http://projects.washingtonpost.com/ncaa/madness/standings/"> Washington Post</a> tourney contests, but not the pool, as it was too boring to fill out. My loss!</p>
<p>Out of 5898 entries in the Washington Post pool, this third bracket placed 52nd; out of what I think were about 3 million ESPN brackets, it finished 33229th. If I had entered it in my brother&#8217;s pool, it would have scored 465 points and won.</p>
<p>Let&#8217;s have a look at round-by-round performance to answer some bracket questions.</p>
<table border="0">
<tbody>
<tr>
<th> </th>
<th>1st</th>
<th>S16</th>
<th>E8</th>
<th>F4</th>
<th>semi</th>
<th>champ</th>
<th>PTS</th>
</tr>
<tr>
<td><strong>My brackets</strong></td>
</tr>
<tr>
<td><a href="http://projects.washingtonpost.com/ncaa/madness/bracket/view/?2699">pundits</a></td>
<td>24</td>
<td>9</td>
<td>6</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>385</td>
</tr>
<tr>
<td><a href="http://projects.washingtonpost.com/ncaa/madness/bracket/view/?4537">Statistics</a></td>
<td>22</td>
<td>10</td>
<td>5</td>
<td>3</td>
<td>1</td>
<td>1</td>
<td>400</td>
</tr>
<tr>
<td><a href="http://projects.washingtonpost.com/ncaa/madness/bracket/view/?2747">PYTHAG</a></td>
<td>24</td>
<td>12</td>
<td>6</td>
<td>4</td>
<td>1</td>
<td>1</td>
<td>465</td>
</tr>
<tr>
<td><strong>Contest winners</strong></td>
</tr>
<tr>
<td><a href="http://games.espn.go.com/tcmen/entry?entryID=2928022">ESPN winner</a></td>
<td>26</td>
<td>13</td>
<td>9</td>
<td>4</td>
<td>2</td>
<td>1</td>
<td>555</td>
</tr>
<tr>
<td><a href="http://projects.washingtonpost.com/ncaa/madness/bracket/view/?2451">WaPost winner</a></td>
<td>26</td>
<td>8</td>
<td>7</td>
<td>4</td>
<td>2</td>
<td>1</td>
<td>475</td>
</tr>
<tr>
<td><strong><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/index.html?eref=T1">CBS pundits</a></strong></td>
</tr>
<tr>
<td><a href="http://splnexperts.mayhem.sportsline.com/print/brackets/printable-bracket/1/16/1/">Denis Dodd</a></td>
<td>23</td>
<td>11</td>
<td>5</td>
<td>3</td>
<td>0</td>
<td>0</td>
<td>360</td>
</tr>
<tr>
<td><a href="http://splnexperts.mayhem.sportsline.com/print/brackets/printable-bracket/1/10/1/">Michael Freeman</a></td>
<td>24</td>
<td>9</td>
<td>4</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>290</td>
</tr>
<tr>
<td><a href="http://splnexperts.mayhem.sportsline.com/print/brackets/printable-bracket/1/8/1/">Gary Parrish</a></td>
<td>23</td>
<td>9</td>
<td>6</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>380</td>
</tr>
<tr>
<td><a href="http://splnexperts.mayhem.sportsline.com/print/brackets/printable-bracket/1/7/1/">Brian De Los Santos</a></td>
<td>23</td>
<td>9</td>
<td>6</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>335</td>
</tr>
<tr>
<td><a href="http://splnexperts.mayhem.sportsline.com/print/brackets/printable-bracket/1/5/1/">Gregg Doyel</a></td>
<td>22</td>
<td>11</td>
<td>5</td>
<td>3</td>
<td>0</td>
<td>0</td>
<td>355</td>
</tr>
<tr>
<td><strong>Washington Post pundit</strong></td>
</tr>
<tr>
<td><a href="http://www.washingtonpost.com/wp-dyn/content/graphic/2008/03/17/GR2008031700635.html">Tony Kornheiser</a></td>
<td>21</td>
<td>9</td>
<td>5</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>355</td>
</tr>
<tr>
<td><strong><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/index.html?eref=T1">CNN/SI pundits</a></strong></td>
</tr>
<tr>
<td><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/luke_winn.html">Luke Winn</a></td>
<td>24</td>
<td>11</td>
<td>6</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>360</td>
</tr>
<tr>
<td><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/grant_wahl.html">Grant Wahl</a></td>
<td>23</td>
<td>10</td>
<td>7</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>385</td>
</tr>
<tr>
<td><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/stewart_mandel.html">Stewart Mandel</a></td>
<td>23</td>
<td>10</td>
<td>7</td>
<td>3</td>
<td>0</td>
<td>0</td>
<td>380</td>
</tr>
<tr>
<td><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/seth_davis.html">Seth Davis</a></td>
<td>20</td>
<td>9</td>
<td>6</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>345</td>
</tr>
<tr>
<td><a href="http://sportsillustrated.cnn.com/basketball/ncaa/men/2008/ncaa_tourney/brackets/experts/kelli_anderson.html">Kelli Anderson</a></td>
<td>23</td>
<td>11</td>
<td>5</td>
<td>3</td>
<td>0</td>
<td>0</td>
<td>360</td>
</tr>
</tbody>
</table>
<ul>
<li><strong>How did the sports pundits do?</strong> Not very well.<sup>1</sup> My brackets beat them.</li>
<li><strong>How did the individual pundits do compared to their consensus?</strong> Only CNN/SI&#8217;s Grant Wahl did as well as the consensus of pundits; the rest had lower scores. Sort of a reversal of the <a href="http://despair.com/meetings.html">conventional wisdom on groupthink</a>. </li>
<li><strong>How well do you have to do to win the ESPN or Washington Post contests?</strong> You need to nail the elite eight and on out. You need a good showing in the first two rounds, but you don&#8217;t have to be perfect. A handful of people in my brother&#8217;s pool got 26 first-round winners correct, the same number as the winners of the Post and ESPN contests. The Post winner only had 8 of the Sweet 16 correct, and if it had been an entry in my brother&#8217;s pool, it would have been mired somewhere in the middle. The ESPN winner picked 13 of the sweet 16&#8211;very good, of course, but at this point it still wouldn&#8217;t have been the leader in my brother&#8217;s pool.</li>
</ul>
<p>It would be interesting to see how well the PYTHAG ratings would have predicted the tournament winners in previous years, although I doubt I&#8217;ll get around to it this year before my interest in bracket-prediction fades. But I think next year I&#8217;ll have to enter a bracket based on it, (and hope that nobody else does the same).</p>
<ol class="footnotes"><li id="footnote_0_72" class="footnote">At least for cheap-o non-ESPN Insider folks like me, the ESPN pundits&#8217; complete brackets weren&#8217;t made available. They did better picking the final four than the CBS or CNN/SI pundits so perhaps they would have done better.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://metcaffeination.net/weblog/2008/04/08/march-madness-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
