Digits of Pi

  • Are there patterns?
  • If not, is it suitable for random number generation?

Method

import matplotlib.pyplot as plt
import numpy as np

with open('pi.txt') as f:
read_data = f.read()

# 0 1 2 3 4 5 6 7 8 9
data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
objects = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for c in read_data:
if c in objects: data[int(c)] += 1

y_pos = np.arange(len(objects))
plt.bar(y_pos, data)
plt.xticks(y_pos, objects)
plt.xlabel('Digit')
plt.ylabel('Instances')
plt.title('Digits of the first 1M of $\pi$')
plt.show()

Results

Conclusion

--

--

--

Software Engineer. 70% of my body is made of code.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating Efficient Data frames Using Pandas

Data Governance Models and the Environmental Context

Connecting Datapoints to a Road Graph with Python Efficiently

Find users of popular services by time and place…

Content Based Filtering

How Can I Scrape Emails From Text Files?

Unsupervised learning for anomaly detection in stock options pricing

📣 Announcement of Airdrop Winners

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Patrick Brown

Patrick Brown

Software Engineer. 70% of my body is made of code.

More from Medium

It’s Simple Math

Paulette Chaffee Offers These 5 Tips to Help Kids Love Math

Learn basic C programming language in just a FEW moments!

A Byte of Coding Issue #220