Last active
December 31, 2015 18:09
-
-
Save aciceri/8025096 to your computer and use it in GitHub Desktop.
Soluzione del problema del compleanno scritta in Python.
http://it.wikipedia.org/wiki/Paradosso_del_compleanno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import matplotlib.pyplot as plt | |
gg = 365 | |
fattoriale = lambda n: 1 if n == 0 else fattoriale(n-1)*n | |
prob_comp = lambda n: 1-(fattoriale(gg)/(fattoriale(gg-n)*gg**n)) | |
if __name__ == '__main__': | |
x = list(range(1, 100)) | |
y = list(map(prob_comp, x)) | |
plt.plot(x, y) | |
plt.xlabel('Persone') | |
plt.ylabel('Probabilità') | |
plt.title('Problema del compleanno') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment