How many digits into pi do you need to go to find your birthday?

[This article was first published on R – Decision Science News, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

FIND YOUR BIRTHDAY IN PI, IN THREE DIFFERENT FORMATS

It was Pi Day (March 14, like 3/14, like 3.14, get it?) recently and Time Magazine did a fun interactive app in which you can find your birthday inside the digits of pi.

However:
1) They only used one format of birthday, in which July 4th would be 704. But there are other ways to write July 4. Like 0704 or 74. And those must be investigated, right?
2) Our friend Dave Pennock said he wanted to see the locations of every possible birthday inside pi.

So here they are. Enjoy! And R code below if you are interested. Plot and other stuff use Hadley Wickham’s Tidyverse tools.

And what the heck, have a spreadsheet of fun (i.e., spreadsheet with all the birthdays and locations in it).

BirthdaylocationShorter formlocationShortest formloc
01-0125631-018531-195
01-0265991-021641-2149
01-03259911-0334871-3111
01-0412191-042701-42
01-0539821-05501-54
01-0610111-0610121-641
01-07232361-0714881-796
01-08162161-0825351-8425
01-0945551-092071-938
01-1032531-101751-10175
01-11196271-111541-11154
01-1244491-127101-12710
01-133621-133631-13363
01-1446781-1427251-142725
01-15275761-159221-15922
01-1657761-163961-16396
01-1762901-17951-1795
01-1877211-184461-18446
01-194941-194951-19495
01-20431721-202441-20244
01-2163051-217111-21711
01-226601-224841-22484
01-23278471-2319251-231925
01-2486191-2410811-241081
01-25154581-2513511-251351
01-2643721-2620141-262014
01-2796931-272981-27298
01-2811991-281491-28149
01-2923411-295001-29500
01-3057481-307451-30745
01-3157421-3110971-311097
02-0198032-012452-194
02-0272872-0215142-2136
02-0338312-0310512-317
02-04281852-043752-4293
02-05126312-0513272-590
02-0698092-068852-67
02-07148392-0723742-729
02-0861412-08772-834
02-09243612-09542-9187
02-1099182-1013182-101318
02-1143532-11942-1194
02-12304742-127122-12712
02-135242-132812-13281
02-14103402-141032-14103
02-15246662-1530992-153099
02-1643842-169922-16992
02-175462-175472-17547
02-1828662-184242-18424
02-197162-197172-19717
02-20157152-2019112-201911
02-21179542-2117372-211737
02-2218892-2217362-221736
02-23251132-231362-23136
02-24127822-245362-24536
02-2530192-2510712-251071
02-2667422-269652-26965
02-27185812-274852-27485
02-2847682-2825282-282528
02-2967072-291862-29186
03-0110453-014933-11
03-0214393-028183-216
03-03153393-031953-325
03-0444603-0444613-487
03-05299853-053663-510
03-0631023-061163-6286
03-0738133-07653-747
03-08352073-085203-818
03-0955843-094213-944
03-1076923-104423-10442
03-11112543-118463-11846
03-12116473-1226323-122632
03-138583-138593-13859
03-1434963-1413-141
03-1582853-153143-15314
03-16130083-162383-16238
03-1747783-171383-17138
03-1872913-187973-18797
03-1945303-1911663-191166
03-2037673-206003-20600
03-21188103-219603-21960
03-22127443-2234343-223434
03-2389483-23163-2316
03-24164753-2424953-242495
03-25125243-2531473-253147
03-2676343-262753-26275
03-2792083-27283-2728
03-28243413-281123-28112
03-29160963-2933333-293333
03-3025683-303653-30365
03-31138523-3111283-311128
04-01196254-0111984-13
04-02176794-0213684-293
04-0347764-037244-324
04-0412724-0412734-460
04-05107484-055964-561
04-06395774-06714-620
04-0742584-0720084-7120
04-0856024-081464-888
04-09337574-093404-958
04-10114954-101634-10163
04-1196554-1124974-112497
04-12201034-122974-12297
04-1364604-1310764-131076
04-1437564-143854-14385
04-1577354-1534-153
04-16102064-1617094-161709
04-17155094-1714194-171419
04-1878474-187284-18728
04-1947904-19374-1937
04-2032864-207024-20702
04-21160284-21934-2193
04-2247964-2218404-221840
04-2382204-2329954-232995
04-2418784-2411104-241110
04-2557164-258224-25822
04-2613924-2613934-261393
04-27369464-276304-27630
04-289104-282034-28203
04-2945144-2912304-291230
04-3046194-305194-30519
05-01218165-0113445-149
05-02251565-02325-2173
05-03197435-038385-39
05-0494755-0419215-4192
05-05365755-051325-5131
05-0620945-0611165-6211
05-076835-076845-7405
05-08146585-0811225-811
05-09171715-0911475-95
05-10102745-10495-1049
05-114445-113955-11395
05-1222945-1218435-121843
05-135975-131105-13110
05-14422365-1421185-142118
05-15104585-1511005-151100
05-1653675-1635165-163516
05-17243655-1721095-172109
05-187515-184715-18471
05-19170965-193905-19390
05-20202475-203265-20326
05-21195535-211735-21173
05-2220415-225355-22535
05-2343175-235795-23579
05-24156355-2416155-241615
05-2532335-2510065-251006
05-2639845-266135-26613
05-2773005-272415-27241
05-28189175-288675-28867
05-2963735-2910595-291059
05-303675-303685-30368
05-31266075-3128715-312871
06-0124006-0112186-1220
06-02148546-022916-221
06-0390196-032646-3313
06-0411726-0411736-423
06-0556816-057506-58
06-06131636-063116-6118
06-07108616-072876-799
06-08139126-086186-8606
06-0933766-091286-942
06-10137046-102696-10269
06-1174486-114276-11427
06-12115856-122206-12220
06-1374906-139716-13971
06-1428876-1416126-141612
06-15250666-1510306-151030
06-1660176-1612066-161206
06-178866-178876-17887
06-18144246-1814446-181444
06-1963516-198436-19843
06-20149676-20766-2076
06-2128196-2128206-212820
06-22302066-221856-22185
06-23515296-234566-23456
06-2454916-245106-24510
06-2559716-2515696-251569
06-26167076-26216-2621
06-2754246-274626-27462
06-28726-28736-2873
06-29119286-295716-29571
06-30109026-3019006-301900
07-01106407-011677-140
07-025447-025457-2140
07-03101087-034087-3300
07-0498827-0426707-457
07-0592337-055617-548
07-0651347-06977-6570
07-0738157-077557-7560
07-0881117-0830617-867
07-0936417-091217-914
07-1031697-106817-10681
07-1142507-1111857-111185
07-1276957-122437-12243
07-13364387-136277-13627
07-1495467-146107-14610
07-1556687-153447-15344
07-16102427-16407-1640
07-17157437-175687-17568
07-1829887-1827767-182776
07-1986647-195417-19541
07-20442217-2010097-201009
07-217567-216507-21650
07-2223757-2221407-222140
07-2333007-2316327-231632
07-2488117-243027-24302
07-25162447-251407-25140
07-262887-262897-26289
07-27123287-274067-27406
07-2848797-2815847-281584
07-2940787-297717-29771
07-3068927-308987-30898
07-3128087-317857-31785
08-0195088-0134188-168
08-02186398-0219938-253
08-0382838-03858-327
08-0412848-047758-419
08-0522928-059578-5172
08-0692898-069688-675
08-07157878-074518-7306
08-0845458-081068-835
08-0930098-0910038-912
08-1032078-102068-10206
08-11108848-111538-11153
08-121478-121488-12148
08-13109818-137348-13734
08-1442748-148828-14882
08-15252578-153248-15324
08-1616018-16688-1668
08-1748578-173198-17319
08-18303998-184908-18490
08-19127868-191988-19198
08-2047878-20538-2053
08-21129238-211028-21102
08-2251498-221358-22135
08-23119578-231148-23114
08-24103588-2411968-241196
08-258288-25898-2589
08-2642948-2620598-262059
08-276198-276208-27620
08-28246148-2823818-282381
08-2911238-293358-29335
08-308168-304928-30492
08-31253558-312378-31237
09-016589-016599-1250
09-0220749-027159-26
09-0363359-033579-315
09-0481079-049099-459
09-05236839-0531919-531
09-0682979-0612949-6181
09-0729869-075439-713
09-0878289-088159-881
09-09120779-092489-945
09-10170099-1028749-102874
09-1161259-1115349-111534
09-12293799-124839-12483
09-13175159-1310969-131096
09-142499-142509-14250
09-1534139-1513159-151315
09-1659309-1633709-163370
09-173419-173429-17342
09-1847319-1822209-182220
09-1921279-194179-19417
09-203289-203299-20329
09-214229-214239-21423
09-2279639-226879-22687
09-23232169-23639-2363
09-2451229-2414309-241430
09-2540089-253379-25337
09-2653809-2669-266
09-2711779-279779-27977
09-2857689-2821929-282192
09-2977859-2918549-291854
09-3014949-301949-30194
10-011576210-011576210-1853
10-02674010-02674010-2164
10-031229210-031229210-33487
10-04384910-04384910-4270
10-05288110-05288110-550
10-06348110-06348110-61012
10-07407610-07407610-71488
10-08828110-08828110-82535
10-09181710-09181710-9207
10-1085310-1085310-10853
10-11384610-11384610-113846
10-12861810-12861810-128618
10-13827110-13827110-138271
10-14278110-14278110-142781
10-15256410-15256410-152564
10-16998710-16998710-169987
10-17804110-17804110-178041
10-18122410-18122410-181224
10-191548310-191548310-1915483
10-20980810-20980810-209808
10-21275010-21275010-212750
10-22640010-22640010-226400
10-23677110-23677110-236771
10-241273610-241273610-2412736
10-251292610-251292610-2512926
10-261467910-261467910-2614679
10-2716410-2716410-27164
10-28324210-28324210-283242
10-29819710-29819710-298197
10-302081910-302081910-3020819
10-31349510-31349510-313495
11-01278011-01278011-1154
11-021272111-021272111-2710
11-03349411-03349411-3363
11-042384211-042384211-42725
11-0517511-0517511-5922
11-061346111-061346111-6396
11-072181911-072181911-795
11-08745011-08745011-8446
11-09325411-09325411-9495
11-102289811-102289811-1022898
11-111270111-111270111-1112701
11-121270211-121270211-1212702
11-13350411-13350411-133504
11-142320911-142320911-1423209
11-152705411-152705411-1527054
11-16399311-16399311-163993
11-1715411-1715411-17154
11-181437611-181437611-1814376
11-1998411-1998411-19984
11-20382311-20382311-203823
11-2171011-2171011-21710
11-221201811-221201811-2212018
11-23654811-23654811-236548
11-242570511-242570511-2425705
11-25135011-25135011-251350
11-261270311-261270311-2612703
11-27425211-27425211-274252
11-281471911-281471911-2814719
11-29445011-29445011-294450
11-30910711-30910711-309107
12-0124412-0124412-1711
12-021994212-021994212-2484
12-036087312-036087312-31925
12-041188512-041188512-41081
12-05332912-05332912-51351
12-06325912-06325912-62014
12-07751112-07751112-7298
12-08371412-08371412-8149
12-09472912-09472912-9500
12-10345612-10345612-103456
12-115028912-115028912-1150289
12-1271112-1271112-12711
12-134750212-134750212-1347502
12-14456012-14456012-144560
12-151194212-151194212-1511942
12-16698612-16698612-166986
12-171107812-171107812-1711078
12-18916712-18916712-189167
12-19142612-19142612-191426
12-203649812-203649812-2036498
12-21873212-21873212-218732
12-221788212-221788212-2217882
12-23955012-23955012-239550
12-2466112-2466112-24661
12-25941712-25941712-259417
12-2696412-2696412-26964
12-2748412-2748412-27484
12-28518312-28518312-285183
12-293041812-293041812-2930418
12-30714612-30714612-307146
12-31945112-31945112-319451

R CODE

library(ggplot2)
library(readr)
library(stringr)
library(tidyr)
pistring = read_file("pi.txt")
#choose 2016 b/c it's a leap year
dayvec = seq(as.Date('2016-01-01'), as.Date('2016-12-31'), by = 1)
dayvec = str_sub(dayvec, start = 6, end = 10)
shorterdayvec = sub("0(.-.)", "\\1", dayvec)
shortestdayvec = sub("(.-)0(.)$", "\\1\\2", shorterdayvec)
df = data.frame(
birthday = dayvec,
loc = str_locate(pistring, gsub("-", "", dayvec))[, 1],
shorter_bday = shorterdayvec,
shorter_loc = str_locate(pistring, gsub("-", "", shorterdayvec))[, 1],
shortest_bday = shortestdayvec,
shortest_loc = str_locate(pistring, gsub("-", "", shortestdayvec))[, 1]
)
write.csv(df, file = "birthdays_in_pi.csv", row.names = FALSE)
long_df = df %>% gather(key, location, loc, shorter_loc, shortest_loc)
p = ggplot(long_df, aes(x = location, fill = key))
p = p + geom_density(alpha = .3)
p = p + coord_cartesian(xlim = c(0, 40000))
p = p + theme(legend.position = "bottom")
p
ggsave(
plot = p,
file = "birthdays_in_pi.pdf",
height = 4,
width = 4
)

The post How many digits into pi do you need to go to find your birthday? appeared first on Decision Science News.

To leave a comment for the author, please follow the link and comment on their blog: R – Decision Science News.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)