aboutsummaryrefslogtreecommitdiff
path: root/SyncRNG.py
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2015-07-30 16:07:50 +0200
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2015-07-30 16:07:50 +0200
commitdec32e1516a05db805ff75a9e016e8bea04d1d8e (patch)
tree1087efc189d5ca533ac01fec6746347212d66202 /SyncRNG.py
parentadded readme (diff)
downloadSyncRNG-dec32e1516a05db805ff75a9e016e8bea04d1d8e.tar.gz
SyncRNG-dec32e1516a05db805ff75a9e016e8bea04d1d8e.zip
name change to SyncRNG and documentation in the .c file
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