From 30ea740b60be37e551deb4d0157595f0bea277a2 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 30 Jul 2015 15:21:28 +0200 Subject: initial commit --- Tausworthe.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Tausworthe.py (limited to 'Tausworthe.py') diff --git a/Tausworthe.py b/Tausworthe.py new file mode 100644 index 0000000..f61fc70 --- /dev/null +++ b/Tausworthe.py @@ -0,0 +1,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()) -- cgit v1.2.3