aboutsummaryrefslogtreecommitdiff
path: root/SyncRNG.py
diff options
context:
space:
mode:
Diffstat (limited to 'SyncRNG.py')
-rw-r--r--SyncRNG.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/SyncRNG.py b/SyncRNG.py
new file mode 100644
index 0000000..7137439
--- /dev/null
+++ b/SyncRNG.py
@@ -0,0 +1,21 @@
+"""
+Simple interface to SyncRNG. This file defines a SyncRNG object which can be
+used to seed and pull numbers from the RNG.
+
+"""
+
+import syncrng
+
+class SyncRNG(object):
+
+ def __init__(self, seed=0):
+ self.seed = seed
+ self.state = syncrng.seed(seed)
+
+ def randi(self):
+ tmp = syncrng.rand(self.state)
+ self.state = tmp[:-1]
+ return(tmp[-1])
+
+ def rand(self):
+ return self.randi() * 2.3283064365387e-10