-
-
Save reem/6433141 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
import numpy.random as nprnd | |
from time import clock | |
def r_step_generator(lo, hi): | |
num = lo | |
diff = hi - lo | |
while True: | |
num += nprnd.randint(0, diff) | |
if num < hi: | |
yield num | |
else: | |
raise StopIteration | |
N = 10 ** 7 | |
t1 = clock() | |
u = range(0, (N // 100) * 99) | |
x = nprnd.randint(0, N, N // 100) | |
for i_x, i_u in enumerate(r_step_generator(0, N)): | |
u.insert(i_u, x[i_x]) | |
t2 = clock() | |
print t2 - t1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment