# Pi vs. e

So a couple days ago I blogged about why I hadn’t ever analyzed e the same way I had analyzed pi awhile back.And today I said to myself, “hey you idiot, what’s your malfunction? Just break up the million digits into chunks, summarize the numbers within, and then combine all the info in an R-friendly table?”
Yeah, what a genius, eh? Proof that any moron can get a Master’s degree.

(Haha, holy hell, I have a Master’s degree. I think that’s the first time I’ve ever written that.)

Anyway.

So I found a list of the first 1 million digits of e here, broke the list into 10 sections of 100,000 digits, summarized the frequencies, made a fancy-shmancy table, plugged it into R, and did an analysis like the one I did to pi. Specifically, I wanted to see exactly how uniform the distribution of digits were in a number with a non-repeating decimal.

Rather than just showing you the results from e (and to have an excuse to screw around with R graphics), I drudged up the data from my pi analysis so I can present to you a few side-by-side comparisons.

Off we go! And as always, pictures are clickable for fullsize.

Here is a table of the digit frequencies, or how often each number (0 through 9) occurred within the first million digits of the two irrational numbers. Since the distribution of these digits is presumably uniform, the expected frequency for each digit is 100,000. As you can see, there’s a slight deviation from this because my sample size is comparatively very tiny.

Cool, huh? And here are comparative pie charts, which aren’t useful at all because the differences in frequencies—both within and across the two irrationals—are so small compared to the number of digits overall. But they were fun to make and they’re pretty, so you get them anyway.

Here’s a better graphic to show a comparison of the frequencies. Number of instances on the y-axis, digits on the x-axis. The red lines/points represent frequencies for e, the blue lines/points represent frequencies for pi. Look at 6. Isn’t that weird how it’s the most frequent digit in e but the least frequent in pi? And check out 3. There was only one more instance of a 3 in the first million digits of pi than there was in the first million digits of e.

How cool, eh?

MATHEMATICS!

### 6 responses

I have a passing interest in number theory, though, and my first thought was that it would be interesting to look at digit frequency in different bases. It’s unfortunate that there is no proof that π and e are ‘normal’ numbers (or, perhaps, actually fortunate, since it would make such games rather less fun) despite there being a general proof that non-normal numbers have Lebesgue measure zero. All we have is some statistical evidence. Normality is kind of a weird property, turns out.

Like

1. Hey, no worries, I Google everyone too.

I never thought about looking at digit frequency in different bases–that may be a project I’ll have to undertake, if for no other reason than to have an excuse to play around with R some more. Normality is indeed a strange property.

Thanks for the comment!

Like

2. 1. i <3 the name of your blog, especially since certain famous writers can't seem to spell eigen correctly, no mr. newspaper columnist turned book author it's NOT igon.
2. how did you get the colors in your pie charts? i can only get rainbow and i need gray scale for publication (and did you catch that, i'm going to publish a paper using pie charts, i hope you're as excited as me)

Like

1. 1. Thanks! I like the word “eigen”…I think I first heard it used in the word “eigengrau,” which is the name for the color we see when we have our eyes closed (yes, I *do* spend too much time on Wikipedia).

2. A paper with pie charts? Nice! There’s an extra line of code you can add under the pie() command to get specific colors for the pie slices; if you want, email me and I can send you my code with an explanation. :)

Like

3. […] Pi vs. e – Alternate title: “R has two subsequent heart attacks.” […]

Like

4. […] (26 views) Pi vs. e […]

Like