Skip to content

Commit 161d217

Browse files
committed
Merge branch 'master' of https://github.com/schmouk/PyRandLib
2 parents d9d8fa2 + 30385e9 commit 161d217

14 files changed

+34
-47
lines changed

PyRandLib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
It is provided under MIT License.
44
Please see files README.md and LICENSE.
55
6-
Copyright (c) 2017-2019 Philippe Schmouker
6+
Copyright (c) 2016-2019 Philippe Schmouker
77
"""
88

99
from .baselcg import BaseLCG

PyRandLib/baselcg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class BaseLCG( BaseRandom ):
3232
"""
3333
Definition of the base class for all LCG pseudo-random generators.
3434
This module is part of library PyRandLib.
35-
36-
Copyright (c) 2017-2019 Philippe Schmouker
3735
36+
Copyright (c) 2016-2019 Philippe Schmouker
3837
3938
LCG models evaluate pseudo-random numbers suites x(i) as a simple mathem-
4039
atical function of

PyRandLib/baselfib64.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class BaseLFib64( BaseRandom ):
3535
on 64-bits generated numbers.
3636
This module is part of library PyRandLib.
3737
38-
Copyright (c) 2017-2019 Philippe Schmouker
39-
38+
Copyright (c) 2016-2019 Philippe Schmouker
4039
4140
Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
4241

PyRandLib/basemrg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class BaseMRG( BaseRandom ):
3434
Definition of the base class for all MRG pseudo-random generators.
3535
This module is part of library PyRandLib.
3636
37-
Copyright (c) 2017-2019 Philippe Schmouker
38-
37+
Copyright (c) 2016-2019 Philippe Schmouker
3938
4039
Multiple Recursive Generators (MRGs) uses recurrence to evaluate pseudo-random
4140
numbers suites. Recurrence is of the form:

PyRandLib/baserandom.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class BaseRandom( Random ):
3333
This is the base class for all pseudo-random numbers generators.
3434
This module is part of library PyRandLib.
3535
36-
Copyright (c) 2017-2019 Philippe Schmouker
37-
36+
Copyright (c) 2016-2019 Philippe Schmouker
3837
3938
See FastRand32 for a 2^32 (i.e. 4.3e+9) period LC-Generator and FastRand63 for a
4039
2^63 (i.e. about 9.2e+18) period LC-Generator with low computation time.

PyRandLib/fastrand32.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ class FastRand32( BaseLCG ):
3636
short time computation.
3737
This module is part of library PyRandLib.
3838
39-
Copyright (c) 2017-2019 Philippe Schmouker
40-
39+
Copyright (c) 2016-2019 Philippe Schmouker
4140
4241
LCG models evaluate pseudo-random numbers suites x(i) as a simple mathem-
4342
atical function of
4443
45-
x(i-1): x(i) = (a*x(i-1) + c) mod m
44+
x(i) = (a * x(i-1) + c) mod m
4645
4746
Results are nevertheless considered to be poor as stated in the
4847
evaluation done by Pierre L'Ecuyer and Richard Simard (Universite de
@@ -65,7 +64,7 @@ class FastRand32( BaseLCG ):
6564
print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
6665
print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
6766
68-
Please notice that for simulating the roll of a dice you should program:
67+
Notice that for simulating the roll of a dice you should program:
6968
diceRoll = FastRand32()
7069
print( int(diceRoll(1, 7)) ) # prints a uniform roll within set {1, 2, 3, 4, 5, 6}
7170
@@ -125,8 +124,8 @@ def setstate(self, _state):
125124
elif isinstance( _state, float ):
126125
# transforms passed initial seed from float to integer
127126
if _state < 0.0 :
128-
inState = -_state
129-
if inState >= 1.0:
127+
_state = -_state
128+
if _state >= 1.0:
130129
self._value = int( _state + 0.5 ) & 0xffffffff
131130
else:
132131
self._value = int( _state * 0x100000000) & 0xffffffff

PyRandLib/fastrand63.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class FastRand63( BaseLCG ):
3636
time computation.
3737
This module is part of library PyRandLib.
3838
39-
Copyright (c) 2017-2019 Philippe Schmouker
40-
39+
Copyright (c) 2016-2019 Philippe Schmouker
4140
4241
LCG models evaluate pseudo-random numbers suites x(i) as a simple mathem-
4342
atical function of
@@ -65,7 +64,7 @@ class FastRand63( BaseLCG ):
6564
print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
6665
print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
6766
68-
Please notice that for simulating the roll of a dice you should program:
67+
Notice that for simulating the roll of a dice you should program:
6968
diceRoll = FastRand63()
7069
print( int(diceRoll(1, 7)) ) # prints a uniform roll within set {1, 2, 3, 4, 5, 6}
7170

PyRandLib/lfib116.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class LFib116( BaseLFib64 ):
3434
Generator with quite short period (8.3e+34).
3535
This module is part of library PyRandLib.
3636
37-
Copyright (c) 2017-2019 Philippe Schmouker
38-
37+
Copyright (c) 2016-2019 Philippe Schmouker
3938
4039
Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
4140
@@ -45,7 +44,7 @@ class LFib116( BaseLFib64 ):
4544
+ (addition),
4645
- (substraction),
4746
* (multiplication),
48-
^(bitwise exclusive-or).
47+
^ (bitwise exclusive-or).
4948
5049
With the + or - operation, such generators are in fact MRGs. They offer very large
5150
periods with the best known results in the evaluation of their randomness, as
@@ -81,7 +80,7 @@ class LFib116( BaseLFib64 ):
8180
print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
8281
print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
8382
84-
Please notice that for simulating the roll of a dice you should program:
83+
Notice that for simulating the roll of a dice you should program:
8584
8685
diceRoll = LFib116()
8786
print(int(diceRoll(1, 7))) # prints a uniform roll within set {1, 2, 3, 4, 5, 6}

PyRandLib/lfib1340.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LFib1340( BaseLFib64 ):
4545
+ (addition),
4646
- (substraction),
4747
* (multiplication),
48-
^(bitwise exclusive-or).
48+
^ (bitwise exclusive-or).
4949
5050
With the + or - operation, such generators are in fact MRGs. They offer very large
5151
periods with the best known results in the evaluation of their randomness, as
@@ -69,7 +69,7 @@ class LFib1340( BaseLFib64 ):
6969
'+'. We've implemented here the original operator: '+'.
7070
7171
See LFib78, LFib116 and LFib668 for long period LFib generators (resp. 2^78,
72-
2^116 and 2^668 periods, i.e. resp. 3.0e+23, 8.3e+34 and 2.4e+403 periods) while
72+
2^116 and 2^668 periods, i.e. resp. 3.0e+23, 8.3e+34 and 1.2e+201 periods) while
7373
same computation time and far higher precision (64-bits calculations) than MRGs,
7474
but memory consumption (resp. 17, 55 and 607 integers).
7575
@@ -81,7 +81,7 @@ class LFib1340( BaseLFib64 ):
8181
print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
8282
print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
8383
84-
Please notice that for simulating the roll of a dice you should program:
84+
Notice that for simulating the roll of a dice you should program:
8585
8686
diceRoll = LFib1340()
8787
print(int(diceRoll(1, 7))) # prints a uniform roll within set {1, 2, 3, 4, 5, 6}

PyRandLib/lfib668.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LFib668( BaseLFib64 ):
4545
+ (addition),
4646
- (substraction),
4747
* (multiplication),
48-
^(bitwise exclusive-or).
48+
^ (bitwise exclusive-or).
4949
5050
With the + or - operation, such generators are in fact MRGs. They offer very large
5151
periods with the best known results in the evaluation of their randomness, as
@@ -58,7 +58,7 @@ class LFib668( BaseLFib64 ):
5858
The implementation of this LFib 64-bits model is based on a Lagged Fibonacci
5959
generator (LFIB) that uses the recurrence
6060
61-
x(i) = (x(i-273) + x(i-607)) mod 2^64
61+
x(i) = ( x(i-273) + x(i-607) ) mod 2^64
6262
6363
and offers a period of about 2^668 - i.e. 1.2e+201 - with low computation time due
6464
to the use of a 2^64 modulo but memory space consumption (607 long integers).
@@ -80,7 +80,7 @@ class LFib668( BaseLFib64 ):
8080
print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
8181
print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
8282
83-
Please notice that for simulating the roll of a dice you should program:
83+
Notice that for simulating the roll of a dice you should program:
8484
8585
diceRoll = LFib668()
8686
print(int(diceRoll(1, 7))) # prints a uniform roll within set {1, 2, 3, 4, 5, 6}

0 commit comments

Comments
 (0)