# Can You Determine Pi From the Digits of Pi?

Happy Pi Day! Isn't Pi Day one of the best holidays all year? For last year's Pi Day, I determined a value of pi without even using a circle. How can you top that? I can top it by using pi to find pi. I know you are thinking: "WHATTT!!! YOU CAN'T DO THAT!" And just who do you think is going to stop me? That's right, no one. Here is the plan: Use the digits of pi to generate pseudo-random numbers. Plot these values as coordinates in an x-y plane. If the coordinate pair has a value of x2 + y2 less than 1, count it "inside a circle." Finally, the number of points "inside" to the total should be the same ratio as the area of a quarter of a circle to the area of a square.

This might be useful. It is an older post where I use the same method to determine pi (Monte Carlo method). Ok. Let's get to work. First, I need some pi. A lot of pi. This isn't too difficult. First google hit for "digits of pi" gave this link to 100,000 digits of pi. After saving that as a text file, I simple made a quick python program that takes 4 digits at a time (I cut off the first "3" – I don't know why). Then made the four digits a "random" number between 0 and 1 alternating groups of 4 digits for x and y coordinates. For example, here are some of the first few digits of pi:

1415926535897932384626433832795028841971693993751058209

So, my first few "random" points would be:

• (0.1415, 0.9265)
• (0.3589, 0.7932)
• (0.3846, 0.2643)

You get the idea. Now for the plot. Here, I have made the data points that have a x2 + y2greater than 1 the color red. The other points are blue. Just to be clear, the square has an "area" of 1 x 1 = 1. The quarter circle has an "area" of pi*(12)/4. I can assume (for random data) that the ratio of numbers of points in these two areas is the same ratio as the areas. Then find this number ratio and solve for pi. With this data, I get pi = 3.175294. Yes, that isn't super close to pi. Still, it was fun. How random are the digits of pi? I am not sure; let's find out. Here are some basic tests for randomness (Wikipedia). Some things to check. Are there equal numbers of 0's, 1's, 2's, etc.? You can do the same thing with double digit numbers (01, 02, 03, ..., 11, 12, ..., etc.). Then you can look at the number times you get five 3's in a row or something or the distances between successive zeros. Let me just first look at the distribution of these "random" numbers. Here is the data split into 10 bins. I am pretty sure this is the same as the frequency test above - except for just the first digit of the 4-digit random number. Let me try breaking this into 100 bins. Ok. That is a little more uneven. Maybe I should look at another distribution. Here are 25,000 points (same number) but generated from a python random number generator. Looks about the same. Good enough for now.

Homework ——–

I will let you take over the rest of this project. Here are some questions for you to answer.

• What if you use more digits of pi? Do you get a better answer?
• Compare this value of pi to the same calculation with 25,000 random numbers (not generated from the digits of pi).
• What if you generate 20,000 five-digit numbers (like 0.12345) instead of 25,000 four-digit numbers? Will this make a difference?
• Further explore the randomness of the digits of pi.

There you go. Maybe those answers will lead to next year's post for Pi Day. I wonder what it will be. Homepage Photo: GJ/Wikimedia
{"ft_lang_label":"__label__en","ft_lang_prob":0.9010967,"math_prob":0.9536266,"size":3414,"snap":"2020-24-2020-29","text_gpt3_token_len":908,"char_repetition_ratio":0.12961876,"word_repetition_ratio":0.0030534351,"special_character_ratio":0.29818395,"punctuation_ratio":0.14980794,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9970021,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,4,null,4,null,4,null,4,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-27T10:38:00Z\",\"WARC-Record-ID\":\"<urn:uuid:ff66abf0-ca70-4cef-9335-24373d085ecd>\",\"Content-Length\":\"106274\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:02c8df40-e168-42db-83bb-bdfa956fe8e2>\",\"WARC-Concurrent-To\":\"<urn:uuid:b9c57cd4-1dd2-41fd-bf67-6d8e0cd65b2b>\",\"WARC-IP-Address\":\"199.232.66.194\",\"WARC-Target-URI\":\"https://www.wired.com/2012/03/can-you-determine-pi-from-the-digits-of-pi/\",\"WARC-Payload-Digest\":\"sha1:7XQYCQLLBKBLKE5OVS6H5WDFTQ3DEWPD\",\"WARC-Block-Digest\":\"sha1:NMGCI5MZQXCXGVXKOVDBEKJUGKHBKYUR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347392142.20_warc_CC-MAIN-20200527075559-20200527105559-00039.warc.gz\"}"}