@@ -123,6 +123,44 @@ Note 3: a Cython version of PyRandLib might be delivered in a next release.
123123Up today, no date is planned for this.
124124
125125
126+ ## New in release 1.2
127+ This is available starting at version 1.2 of PyRandLib. The call operator
128+ (i.e., '()') gets a new signature which is still backward compatible with
129+ previous versions of this library. Its new use is described here below. The
130+ implementation code can be found in class ` BaseRandom ` , in module
131+ ` baserandom.py ` .
132+
133+ from fastrand63 import FastRand63
134+
135+ rand = FastRand63()
136+
137+ # prints a float random value ranging in [0.0, 1.0]
138+ print( rand() )
139+
140+ # prints an integer random value ranging in [0, 5]
141+ print( rand(5) )
142+
143+ # prints a float random value ranging in [0.0, 20.0]
144+ print( rand(20.0)
145+
146+ # prints a list of 10 integer values each ranging in [0, 5]
147+ print( rand(5, 10) )
148+
149+ # prints a list of 10 float values each ranging in [0.0, 1.0]
150+ print( rand(times=10) )
151+
152+ # prints a list of 4 random values ranging respectively in
153+ # [0, 5], [0.0, 50.0], [0.0, 500.0] and [0, 5000]
154+ print( rand(5, 50.0, 500.0, 5000) )
155+
156+ # a more complex call which prints something like:
157+ # [ [3, 11.64307079016269, 127.65395855782158, 4206, [2, 0, 1, 4, 4, 1, 2, 0]],
158+ # [2, 34.22526698212995, 242.54183578253426, 2204, [5, 3, 5, 4, 2, 0, 1, 3]],
159+ # [0, 17.77303802057933, 417.70662295909983, 559, [4, 1, 5, 0, 5, 3, 0, 5]] ]
160+ print( rand( (5, 50.0, 500.0, 5000, [5]*8), times=3 ) )
161+
162+
163+
126164## Architecture overview
127165Each of the implemented PRG is described in an independent module. The name
128166of the module is directly related to the name of the related class.
@@ -136,7 +174,7 @@ aims at providing simple common behavior for all PRG classes of the library,
136174the most noticeable one being the 'callable' nature of every implemented
137175PRGs. For instance:
138176
139- rand = UBaseRandom ()
177+ rand = BaseRandom ()
140178 print( rand() ) # prints a uniform pseudo-random value within [0.0, 1.0)
141179 print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
142180 print( rand(a,b) ) # prints a uniform pseudo-random value within [a, b)
0 commit comments