- #1
Othman0111
- 27
- 0
Hi everyone,
I'm trying to create a sequence that evaluates r for i= 1 to 10 and 100 to 110 ...N (evaluate 10 skip 90 repeats till N).
If python has a GoTo function, I would've used it to return the previous line to repeat. But I couldn't find a function like that anywhere on the internet.
1. Homework Statement
Martin Lüscher’s scheme to fix poor random-number generators is to generate a small block of random deviates, then “throw away” a large block, causing the generator to “forget” about the small block and iterate. For example, you can generate and store 10 values, then generate and discard 90 values, then generate and store another 10 values, etc. Try this quick fix in the examples above and see if things improve. The experiment also with different lengths of the short/long blocks you store/discard. Comment and document your findings.
Σa(a+10) r(i)
a=100i
where i = 0,1,2,3,4,...N
I'm trying to create a sequence that evaluates r for i= 1 to 10 and 100 to 110 ...N (evaluate 10 skip 90 repeats till N).
If python has a GoTo function, I would've used it to return the previous line to repeat. But I couldn't find a function like that anywhere on the internet.
1. Homework Statement
Martin Lüscher’s scheme to fix poor random-number generators is to generate a small block of random deviates, then “throw away” a large block, causing the generator to “forget” about the small block and iterate. For example, you can generate and store 10 values, then generate and discard 90 values, then generate and store another 10 values, etc. Try this quick fix in the examples above and see if things improve. The experiment also with different lengths of the short/long blocks you store/discard. Comment and document your findings.
Homework Equations
Σa(a+10) r(i)
a=100i
where i = 0,1,2,3,4,...N
The Attempt at a Solution
Python:
%matplotlib inline
import numpy as np
from matplotlib import pyplot
import itertools as it
N = 5002
r = np.zeros(N+1)
M = np.zeros(N+1)
j = np.zeros(N+1)
coef = 523612312121
bigint = 65379170218971
i=0
a=100*i
M=100*i+10
seed = 1.
r[0] = seed
for i in range(a,M):
r[i] = (coef*r[i-1])%bigint
for i in it.repeat(r[i], 10):
if i<=N: #GO TO LINE 11
r1 = np.zeros(N//2)
r2 = np.zeros(N//2)
for i in range(0,N,2):
r1[i//2] = float(r[i])/float(bigint)
r2[i//2] = float(r[i+1])/float(bigint)
pyplot.plot(r1,r2,marker='o',linestyle='None');