2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-28 23:37:57 +02:00
LaTeX-examples/tikz/birthday-paradox/calculate.py

15 lines
328 B
Python
Raw Normal View History

2012-08-09 07:04:38 +02:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
from math import factorial
from gmpy import bincoef
f = open('data.csv', 'w')
f.write('People\tprobability\n')
def prob(people):
return 1.0 - float(factorial(people)*bincoef(365,people))/(365**people)
for people in xrange(60+1):
f.write("%i\t%f\n" % (people, prob(people)))