@@ -23,37 +23,36 @@ which can fully reproduce the sequence produced by NumPy.
23
23
24
24
* Replacement for NumPy's RandomState
25
25
26
- ``` python
27
- # import numpy.random as rnd
28
- from randomgen import RandomGenerator, MT19937
29
- rnd = RandomGenerator(MT19937())
30
- x = rnd.standard_normal(100 )
31
- y = rnd.random_sample(100 )
32
- z = rnd.randn(10 ,10 )
33
- ```
26
+ ``` python
27
+ from randomgen import RandomGenerator, MT19937
28
+ rnd = RandomGenerator(MT19937())
29
+ x = rnd.standard_normal(100 )
30
+ y = rnd.random_sample(100 )
31
+ z = rnd.randn(10 ,10 )
32
+ ```
34
33
35
34
* Default random generator is a fast generator called Xoroshiro128plus
36
35
* Support for random number generators that support independent streams
37
36
and jumping ahead so that sub-streams can be generated
38
37
* Faster random number generation, especially for normal, standard
39
38
exponential and standard gamma using the Ziggurat method
40
39
41
- ``` python
42
- from randomgen import RandomGenerator
43
- # Use Xoroshiro128
44
- rnd = RandomGenerator()
45
- w = rnd.standard_normal(10000 , method = ' zig' )
46
- x = rnd.standard_exponential(10000 , method = ' zig' )
47
- y = rnd.standard_gamma(5.5 , 10000 , method = ' zig' )
48
- ```
40
+ ``` python
41
+ from randomgen import RandomGenerator
42
+ # Default basic PRNG is Xoroshiro128
43
+ rnd = RandomGenerator()
44
+ w = rnd.standard_normal(10000 , method = ' zig' )
45
+ x = rnd.standard_exponential(10000 , method = ' zig' )
46
+ y = rnd.standard_gamma(5.5 , 10000 , method = ' zig' )
47
+ ```
49
48
50
49
* Support for 32-bit floating randoms for core generators.
51
50
Currently supported:
52
51
53
- * Uniforms (` random_sample ` )
54
- * Exponentials (` standard_exponential ` , both Inverse CDF and Ziggurat)
55
- * Normals (` standard_normal ` )
56
- * Standard Gammas (via ` standard_gamma ` )
52
+ * Uniforms (` random_sample ` )
53
+ * Exponentials (` standard_exponential ` , both Inverse CDF and Ziggurat)
54
+ * Normals (` standard_normal ` )
55
+ * Standard Gammas (via ` standard_gamma ` )
57
56
58
57
** WARNING** : The 32-bit generators are ** experimental** and subject
59
58
to change.
@@ -64,10 +63,10 @@ y = rnd.standard_gamma(5.5, 10000, method='zig')
64
63
* Support for filling existing arrays using ` out ` keyword argument. Currently
65
64
supported in (both 32- and 64-bit outputs)
66
65
67
- * Uniforms (` random_sample ` )
68
- * Exponentials (` standard_exponential ` )
69
- * Normals (` standard_normal ` )
70
- * Standard Gammas (via ` standard_gamma ` )
66
+ * Uniforms (` random_sample ` )
67
+ * Exponentials (` standard_exponential ` )
68
+ * Normals (` standard_normal ` )
69
+ * Standard Gammas (via ` standard_gamma ` )
71
70
72
71
## Included Pseudo Random Number Generators
73
72
@@ -84,9 +83,11 @@ The RNGs include:
84
83
[ xorshift1024* φ] ( http://xorshift.di.unimi.it/ )
85
84
* [ PCG64] ( http://www.pcg-random.org/ )
86
85
* ThreeFry and Philox from [ Random123] ( https://www.deshawresearch.com/resources_random123.html )
86
+
87
87
## Differences from ` numpy.random.RandomState `
88
88
89
89
### New Features
90
+
90
91
* ` standard_normal ` , ` normal ` , ` randn ` and ` multivariate_normal ` all
91
92
use the much faster (100%+) Ziggurat method.
92
93
* ` standard_gamma ` and ` gamma ` both use the much faster Ziggurat method.
@@ -101,21 +102,20 @@ The RNGs include:
101
102
` out ` keyword argument
102
103
* Standardizes integer-values random values as int64 for all platforms.
103
104
104
-
105
105
### New Functions
106
106
107
- * ` random_entropy ` - Read from the system entropy provider, which is
108
- commonly used in cryptographic applications
109
- * ` random_raw ` - Direct access to the values produced by the underlying
110
- PRNG. The range of the values returned depends on the specifics of the
111
- PRNG implementation.
107
+ * ` random_entropy ` - Read from the system entropy provider, which is
108
+ commonly used in cryptographic applications
109
+ * ` random_raw ` - Direct access to the values produced by the underlying
110
+ PRNG. The range of the values returned depends on the specifics of the
111
+ PRNG implementation.
112
112
* ` random_uintegers ` - unsigned integers, either 32- (` [0, 2**32-1] ` )
113
- or 64-bit (` [0, 2**64-1] ` )
114
- * ` jump ` - Jumps RNGs that support it. ` jump ` moves the state a great
115
- distance. _ Only available if supported by the RNG._
116
- * ` advance ` - Advanced the RNG 'as-if' a number of draws were made,
117
- without actually drawing the numbers. _ Only available if supported by
118
- the RNG._
113
+ or 64-bit (` [0, 2**64-1] ` )
114
+ * ` jump ` - Jumps RNGs that support it. ` jump ` moves the state a great
115
+ distance. _ Only available if supported by the RNG._
116
+ * ` advance ` - Advanced the RNG 'as-if' a number of draws were made,
117
+ without actually drawing the numbers. _ Only available if supported by
118
+ the RNG._
119
119
120
120
## Status
121
121
@@ -126,53 +126,70 @@ the RNG._
126
126
* Windows 32/64 bit, Python 2.7, 3.5 and 3.6
127
127
128
128
## Version
129
- The version matched the latest version of NumPy where
129
+
130
+ The version matched the latest version of NumPy where
130
131
` RandomGenerator(MT19937()) ` passes all NumPy test.
131
132
132
133
## Documentation
133
134
134
135
Documentation for the latest release is available on
135
- [ my GitHub pages] ( http://bashtage.github.io/randomgen/ ) . Documentation for
136
- the latest commit (unreleased) is available under
136
+ [ my GitHub pages] ( http://bashtage.github.io/randomgen/ ) . Documentation for
137
+ the latest commit (unreleased) is available under
137
138
[ devel] ( http://bashtage.github.io/randomgen/devel/ ) .
138
139
139
140
## Plans
141
+
140
142
This module is essentially complete. There are a few rough edges that
141
143
need to be smoothed.
142
144
143
- * Creation of additional streams from where supported
145
+ * Creation of additional streams from where supported
144
146
(i.e. a ` next_stream() ` method)
145
147
146
148
## Requirements
147
149
Building requires:
148
150
149
- * Python (2.7, 3.4, 3.5, 3.6)
150
- * NumPy (1.11, 1.12, 1.13, 1.14, 1.15)
151
- * Cython (0.26+)
152
- * tempita (0.5+), if not provided by Cython
151
+ * Python (2.7, 3.4, 3.5, 3.6)
152
+ * NumPy (1.11, 1.12, 1.13, 1.14, 1.15)
153
+ * Cython (0.26+)
154
+ * tempita (0.5+), if not provided by Cython
153
155
154
156
Testing requires pytest (3.0+).
155
157
156
- ** Note:** it might work with other versions but only tested with these
157
- versions.
158
+ ** Note:** it might work with other versions but only tested with these
159
+ versions.
158
160
159
161
## Development and Testing
160
162
161
- All development has been on 64-bit Linux, and it is regularly tested on
163
+ All development has been on 64-bit Linux, and it is regularly tested on
162
164
Travis-CI (Linux/OSX) and Appveyor (Windows). The library is occasionally
163
165
tested on Linux 32-bit and Free BSD 11.1.
164
166
165
- Basic tests are in place for all RNGs. The MT19937 is tested against
167
+ Basic tests are in place for all RNGs. The MT19937 is tested against
166
168
NumPy's implementation for identical results. It also passes NumPy's
167
169
test suite where still relevant.
168
170
169
171
## Installing
170
172
173
+ Either install from PyPi using
174
+
175
+ ``` bash
176
+ pip install randomgen
177
+ ```
178
+
179
+ or, if you want the latest version,
180
+
181
+ ``` bash
182
+ pip install git+https://github.com/bashtage/randomgen.git
183
+ ```
184
+
185
+ or from a cloned repo,
186
+
171
187
``` bash
172
188
python setup.py install
173
189
```
174
190
175
191
### SSE2
192
+
176
193
` dSFTM ` makes use of SSE2 by default. If you have a very old computer
177
194
or are building on non-x86, you can install using:
178
195
@@ -181,12 +198,12 @@ python setup.py install --no-sse2
181
198
```
182
199
183
200
### Windows
201
+
184
202
Either use a binary installer, or if building from scratch, use
185
203
Python 3.6 with Visual Studio 2015/2017 Community Edition. It can also
186
204
be build using Microsoft Visual C++ Compiler for Python 2.7 and
187
205
Python 2.7.
188
206
189
-
190
207
## Using
191
208
192
209
The separate generators are importable from ` randomgen `
@@ -205,46 +222,46 @@ rg.random_sample(100)
205
222
```
206
223
207
224
## License
225
+
208
226
Standard NCSA, plus sub licenses for components.
209
227
210
228
## Performance
211
- Performance is promising, and even the mt19937 seems to be faster than
212
- NumPy's mt19937.
213
229
214
- ```
215
- Speed-up relative to NumPy (Uniform Doubles)
216
- ************************************************************
217
- DSFMT 137.1%
218
- MT19937 21.0%
219
- PCG32 101.2%
220
- PCG64 110.7%
221
- Philox -2.7%
222
- ThreeFry -11.4%
223
- ThreeFry32 -62.3%
224
- Xoroshiro128 181.4%
225
- Xorshift1024 141.8%
226
-
227
- Speed-up relative to NumPy (64-bit unsigned integers)
228
- ************************************************************
229
- DSFMT 24.8%
230
- MT19937 15.0%
231
- PCG32 92.6%
232
- PCG64 99.0%
233
- Philox -20.4%
234
- ThreeFry -21.7%
235
- ThreeFry32 -64.4%
236
- Xoroshiro128 164.2%
237
- Xorshift1024 120.8%
238
-
239
- Speed-up relative to NumPy (Standard normals)
240
- ************************************************************
241
- DSFMT 299.4%
242
- MT19937 271.2%
243
- PCG32 364.5%
244
- PCG64 364.2%
245
- Philox 256.9%
246
- ThreeFry 236.0%
247
- ThreeFry32 97.0%
248
- Xoroshiro128 477.4%
249
- Xorshift1024 360.7%
250
- ```
230
+ Performance is promising, and even the mt19937 seems to be faster than
231
+ NumPy's mt19937.
232
+
233
+ Speed-up relative to NumPy (Uniform Doubles)
234
+ ************************************************************
235
+ DSFMT 137.1%
236
+ MT19937 21.0%
237
+ PCG32 101.2%
238
+ PCG64 110.7%
239
+ Philox -2.7%
240
+ ThreeFry -11.4%
241
+ ThreeFry32 -62.3%
242
+ Xoroshiro128 181.4%
243
+ Xorshift1024 141.8%
244
+
245
+ Speed-up relative to NumPy (64-bit unsigned integers)
246
+ ************************************************************
247
+ DSFMT 24.8%
248
+ MT19937 15.0%
249
+ PCG32 92.6%
250
+ PCG64 99.0%
251
+ Philox -20.4%
252
+ ThreeFry -21.7%
253
+ ThreeFry32 -64.4%
254
+ Xoroshiro128 164.2%
255
+ Xorshift1024 120.8%
256
+
257
+ Speed-up relative to NumPy (Standard normals)
258
+ ************************************************************
259
+ DSFMT 299.4%
260
+ MT19937 271.2%
261
+ PCG32 364.5%
262
+ PCG64 364.2%
263
+ Philox 256.9%
264
+ ThreeFry 236.0%
265
+ ThreeFry32 97.0%
266
+ Xoroshiro128 477.4%
267
+ Xorshift1024 360.7%
0 commit comments