Files
  • main.py
  • plot.png
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import matplotlib.pyplot as plt

n1 = 50

l = np.zeros(n1-1)

for n in range(2,n1+1):

	c = 0
	n0=30000

	for i in range(n0):
		t = list(np.round_(np.random.randint(low=1, high=365, size=(n,))))
		for i in t:
			if t.count(i) > 1:
				c+=1
				break

	print(n,c/n0)
	l[n-2] = c/n0

plt.plot(l,"rx")
plt.ylabel("Probabilty of 2 People Sharing a Birthday")
plt.xlabel("Number of People")
plt.savefig("plot.png")