Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def sample(N=2):
while True:
S_N_minus_1 = sum([random() for _ in xrange(N-1)])
if S_N_minus_1 >= 1:
continue
uN = random()
if S_N_minus_1 + uN >= 1:
return uN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment