#-*-coding:utf8-*- from random import randint def xor(u,v): return int(u==v) def xorshift(x, a, b, c): # x ^= x >> 12; // a y = x[a:]+x[:a] z = [xor(x[k],y[k]) for k in range(len(x))] # x ^= x << 25; // b y = x[:b]+x[b:] z = [xor(z[k],y[k]) for k in range(len(x))] # x ^= x >> 27; // c y = x[c:]+x[:c] return [xor(z[k],y[k]) for k in range(len(x))] def lcg(x,a,c,m): #Xn+1=(a⋅Xn+c)%m return (a*x+c)%m x = [randint(0,1) for k in range(32)] liste = [] for k in range(10): liste += x x = xorshift(x, 12, 25, 27) print liste print liste.count(0), liste.count(1) x = randint(0,100) liste = [] for k in range(10): liste.append(x) x = lcg(x, 12, 25,27) print liste