#acl +All:read #format wiki #language ko #pragma description Birthday paradox; ==== Birthday Paradox ==== [[WikiPedia:Birthday_problem|Birthday Paradox]]: 23명이 모이면 그 안에 생일이 같은 사람이 존재할 확률은 50% 이상. * 2014 FIFA 월드컵 본선 진출 32팀(각 팀 23명) 중 생일이 같은 멤버가 있던 팀은 16팀이었음 ([[http://www.bbc.co.uk/news/magazine-27835311|BBC]]) * [[http://betterexplained.com/articles/understanding-the-birthday-paradox/|참고자료]] 계산해보자 ([[Python]]) {{{#!highlight python person = 23 odd = 1.0 for x in range(2,person+1): odd = odd * (366 - x)/365 print x, "person:", (1-odd)*100, "%" }}} 랜덤 생일 23개로 이루어진 그룹 10000개를 생성하고 그 중 같은 생일이 있는 그룹이 몇 개인지 헤아리는 시뮬레이션 [[Python]] Code {{{#!highlight python import random class Birthday: def __init__(self, n=23): self.birthday = [] for x in range(n): self.birthday.append(int(random.random()*365)) def shared(self): seen = [] for value in self.birthday: if value not in seen: seen.append(value) else: return True return False total = 10000 shared = 0 for x in range(total): birthday = Birthday() if birthday.shared(): shared = shared +1 print shared, "groups out of", total, "have members sharing the same birthday." }}}