Skip to content

Instantly share code, notes, and snippets.

@RobinCPC
Created February 19, 2014 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinCPC/9096989 to your computer and use it in GitHub Desktop.
Save RobinCPC/9096989 to your computer and use it in GitHub Desktop.
random declare variable and avoid variable over number range (e. g. keep angle in 0~ 2 pi)
#
from math import *
import random
N = 1000
index = int(random.random() * N) # randomly pick a starting index
for i in range(N):
index = (index + 1) % N # keep index in side 0~1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment