Monday, June 30, 2014

Animated map of earthquakes near China and Japan, 1970-2013

If you prefer, you can watch this as a GIF or on YouTube.

The animation above shows all earthquakes with epicenters in the bounded area and magnitudes greater than 5.0. The first slide says "Richter scale" because that's most familiar to most people, but the actual scale used was the Moment Magnitude Scale; it's generally within a few decimals of the 1930s-era Richter.

The data is from IRIS (the Incorporated Research Institute for Seismology), the maps were produced using Python with Pandas, Matplotlib and Basemap, and the animation with GIMP and HTML5 conversion with gfycat.

The width of the circles is the result of a compromise relationship between magnitude scale number, circle area, perceived circle size difference and total energy release. I chose a scale that (a) was intermediate between the extremes of size every approach suggested, and (b) had a simple formula so that it would be, at the very least, transparent:
circle size = 20 pixels * (magnitude - 4.5) ^ 1.5
As you can see, it's arbitrary, but there is no non-arbitrary scale that is not equally misleading in certain respects, which is probably why IRIS does not vary the circle size at all in their maps, instead indicating intensity with color (which has its own perceptual issues, unfortunately: pdf).

The main thing to note is that the circle size is somewhat related to the area on the surface affected by the earthquake, but the relationship is very fuzzy. Different geographical features affect the distance earthquakes travel; faults, for example, actually contain them in a smaller area. In the animation, the most important difference in scale to show is that earthquakes of magnitude 5.0, which can be felt and are alarming but generally cause little damage in areas prepared for them, are small circles, and the 42 quakes with magnitude 7 or above are quite perceptually different.

Feel free to disagree and comment. As usual, I don't claim to have found the solution to a quandary, just a solution, and I'm sure there are better ideas out there.

As you watch the animation, you may want to keep an eye out for the following notable earthquakes (and you'll also notice a lot of large earthquakes that are not notable, because thankfully the damage they caused was not in proportion to their magnitude).

 •  July 1976: The Tangshan Earthquake (magnitude 7.5) on the northern Chinese coast near Korea. The deadliest earthquake of the 20th century, killing between 250,000 and 650,000 people.
 •  January 1995: 7.3 The Great Hanshin Earthquake (magnitude 7.3) near Kobe in southern Japan, caused $100 billion in damage, 2.5% of Japan's GDP at the time
 •  September 1999: The 9/21 Earthquake (magnitude 7.5) in Taiwan (at the very bottom edge of this map)
 •  May 2008: The Great Sichuan Earthquake (magnitude 7.9) in central China, killed 70,000
 •  March 2011: The Tōhoku earthquake (magnitude 9.0) and tsunami, the fifth largest earthquake in modern times; hundreds of huge aftershocks appear on the map all the way through December 2013.

Wednesday, June 25, 2014

Pi vs. tau: Ultimate Smackdown

Spoiler alert: there's only a 0.1% chance any given 1-800 number will be found in pi or tau.

What's tau, you ask? Tau is two times pi, or as mathematicians like to put i, τ = 2 π. It turns out that in many endeavors, 2π is a more useful number in calculations than π.

pi ≅ 3.1415926535... et cetera ad infinitum
tau ≅  6.2831853071... yadda yadda

Tau is the brainchild of Michael Hartl, who launched a website in 2010 to suggest it, complete with a manifesto, and it's gotten a certain amount of traction. Personally, I like tau's unique combination of utility, whimsy and hubris for taking on the most famous fancy number in the world.

In honor of Tau Day 2014 (6/28, naturally), I've decided to settle this thing once and for all with a series of competitions between pi and tau to determine which is the better number. More useful in geometry? Better for calculating flow rate in pipes? Meh, who cares? I'm more interested in which one displays more interesting arbitrary properties.

In order to make this comparison, I calculated tau to one billion (1,000,000,000) digits, since only 100,000 digits were available. I am making the fruits of my labor available to all, you can download the 390 MB compressed text files here. That's right, baby, I singlehandedly increased the available digits of tau by a factor of 10,000. How did I do it? Well, I took pi and ... wait for it ... I multiplied it by two. Thank goodness I learned how to carry the one over 500 million times. Hey, it took my computer almost twenty minutes, that's an eternity for a multiplication (Yes, I did it in batches).

Before the games begin, I'd like to encourage those of you for whom this post just isn't geeky and long enough to check out my companion blog, prooffreaderplus, which has more data, more graphs, more ruminations. The thinking kind of rumination, not the cow kind. Oh, and there's a related webcomic I published earlier today too.

And yes, I realize many of the results of this competition would be different if humans normally had 12 fingers.

Round one: How "randomesque" are the digits?

I'm using "randomesque" because random is totally the wrong word (see prooffreaderplus for more in that vein), but you know what I mean: are the digits uniformly distributed so that there are about the same number of zeroes, ones, twos, etc cumulatively at any given digit? Let's look at the cumulative digit averages (for an equal distribution it would be 4.5) and the r-squareds compared to a uniform distribution:

You can see that early on, tau is consistently above the ideal average, and pi, except for a brief surge before digit 162, is below. This is similar to the random walk simulation that computer programmers and others learn. We would expect a randomesque number to dip above and below the line, which pi does more often than tau. Over the first 1,000 digits, pi is closer to 4.5 than tau 59 times more than the reverse; so let's call pi the winner by a nose.

A randomesque number should have a high r-squared compared to equal distribution. This one is tough to call; on the one hand, pi's R squared is greater than tau's 80% of the time in the first 1,000 digits. However, the biggest differences between the two belong to tau early on. I call this a draw.

This round goes to pi by the slimmest of margins. Can tau make up the gap in the second and final round? Isn't this exciting? Are you not entertained?

Round two: How many totally arbitrary patterns can we find?

This competition is sort of the opposite of the previous, since the more "randomesque" a number is, there fewer patterns we should find. But it's human nature to want contradictory things (freedom and security? yeah, I went there), so here goes.

First of all, I have some devastating news. As mentioned above, the odds of finding a particular 11-digit number among the first billion are approximately 0.9949%, so it's understandable that, tragically, the phone number corresponding to 1-800-SIR-MIX-A-LOT does not appear in the first billion digits of either pi or tau. (And yes, I truncated it to 11 digits, 1-800-SIR-MIX-A-. The chance of finding a fourteen-digit number is 0.0009989%.)

Thank you to self-described tauist Ben Weiss, who went above and beyond the call by actually verifying one of the numbers below; it was, erm, a little off. I verified some of the results and thought that meant they were all correct. Thankfully, nothing substantial was wrong, and I've corrected the mistakes. I think. Caveat emptor, always.

"Jenny's number" (867-5309) is a different story: pi has it earlier (digit 9,202,590 to 10,224,730 for tau) and more often (102 to 94 times). A point for pi, and a well-deserved acknowledgement of the genius of Tommy Tutone.

The first possible 1-800 number in tau is 1-800-647-6185 at digit 8985, over 14,000 digits earlier than pi's 1-800-469-6169. A point for tau. (A Google search of both numbers turns up nothing; too bad, one of them could have had a great claim to fame! I'm too chicken to try dialing them, let me know if you do.)

How about repeated digits? It's a wash. They both have the same maximum number of consecutive repeated digits at almost the same position, which makes sense since τ = 2 π: pi's 666666666667 at digit 45,681,780 becomes tau's 933333333333. Draw.

Tau wins the Fibonacci sequence search: pi only goes up to 11235813 at position 48,300,973, but most of the way to a billion, at 809,073,288, tau adds the next number, 21.
Pi edges tau in consecutive even, odd, prime and binary numbers, but tau takes it away with longest stretch without a number: more than a third of the way to a billion, at digit 362,783,626, there is a stretch of 210 digits without the number 6, blowing away pi's 196-digit stretch without an 8. This one to tau by a nose.

Finally, the coolest thing in my opinion is for a number to recapitulate itself. At digit 50,366,471 pi has 31415926... eight digits, not bad. What about tau? It gets one digit, recapitulating itself to nine places almost halfway to a billion, at position at 405,747,242! Not only that, tau recapitulates pi even better than pi does: 9 digits, only at position 52,567,169!

By my count, we have a winner.

And the winner is:

If you want to calculate the circumference of any of those firework circles, I know a good number you can use. And if any other number objects, they can shut their pi hole.

Thursday, June 12, 2014

Popular Posts

Scroll To Top