diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2015-07-30 15:21:28 +0200 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2015-07-30 15:21:28 +0200 |
| commit | 30ea740b60be37e551deb4d0157595f0bea277a2 (patch) | |
| tree | cef294510a5154d205fb1b7930fcaf3ae617a56e /Tausworthe.py | |
| download | SyncRNG-30ea740b60be37e551deb4d0157595f0bea277a2.tar.gz SyncRNG-30ea740b60be37e551deb4d0157595f0bea277a2.zip | |
initial commit
Diffstat (limited to 'Tausworthe.py')
| -rw-r--r-- | Tausworthe.py | 22 |
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()) |
