#!/usr/bin/env python

import sys
import random
import matplotlib.pyplot as plt

N = 100000
seed = 42

if len(sys.argv) > 1: N = int(sys.argv[1])
if len(sys.argv) > 2: seed = int(sys.argv[2])

random.seed(seed)

sum = 0
xcirc = []
ycirc = []
for i in range(N):
    x = random.uniform(-1,1)
    y = random.uniform(-1,1)
    if x**2 + y**2 <= 1:
        xcirc.append(x)
        ycirc.append(y)
        sum += 1

print ('pi =', 4*float(sum)/N)

plt.xlim(-1,1)
plt.ylim(-1,1)
plt.axes().set_aspect('equal')
plt.plot(xcirc, ycirc, 'b.', markersize=0.5)
plt.show()



