Skip to content

Instantly share code, notes, and snippets.

@songouyang
Created March 24, 2018 15:30
Show Gist options
  • Select an option

  • Save songouyang/9920cd785fd1c9dcefcac64288ff64cd to your computer and use it in GitHub Desktop.

Select an option

Save songouyang/9920cd785fd1c9dcefcac64288ff64cd to your computer and use it in GitHub Desktop.
等概率抽样
import random
def get_ran(m, n):
for i in range(n):
if(random.randint(0, n-i-1) < m):
print(i, end="")
m -= 1
print()
if __name__ == "__main__":
for _ in range(200):
get_ran(2, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment