Traditional Culture Encyclopedia - Weather forecast - Solving "Birthday Paradox" with python Programming

Solving "Birthday Paradox" with python Programming

Random import

def bdp(n,k):

cv = []

For I in the range (k):

m = []

For j in the range (n):

m . append(random . randint( 1,365))

Counter = 0

For k 1 in m:

For k2 in m:

If k 1 == k2:

Counter += 1

cv . append(float(counter/2)/float(n))

ss = 0

For I in cv:

ss += i

Back to ss/float(len(cv))

You can use Pro-test: