aboutsummaryrefslogtreecommitdiff
path: root/Tausworthe.py
blob: f61fc70969dd214522bf1de28be8b375a16032c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import taus

class TauswortheRNG(object):

    def __init__(self, seed=0):
        self.seed = seed
        self.state = taus.seed(seed)

    def randi(self):
        tmp = taus.rand(self.state)
        self.state = tmp[:-1]
        return(tmp[-1])

    def rand(self):
        return self.randi() * 2.3283064365387e-10


if __name__ == '__main__':
    t = TauswortheRNG(112339)
    for i in range(1000000):
        print(t.randi())