aboutsummaryrefslogtreecommitdiff
path: root/Tausworthe.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tausworthe.py')
-rw-r--r--Tausworthe.py22
1 files changed, 22 insertions, 0 deletions
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())