Created
September 11, 2016 13:33
-
-
Save CamDavidsonPilon/1e55dd74bfc1d65aeb6213cfc6ffc4e7 to your computer and use it in GitHub Desktop.
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
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