Skip to content

Commit 768c26e

Browse files
committed
Merge pull request #29 from bashtage/defaults-pxi
Defaults pxi
2 parents aa2a303 + 1078941 commit 768c26e

File tree

22 files changed

+394
-113
lines changed

22 files changed

+394
-113
lines changed

doc/source/dsfmt.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Random generator
1515
get_state
1616
set_state
1717

18+
Parallel generation
19+
===================
20+
.. autosummary::
21+
:toctree: generated/
22+
23+
jump
1824

1925
Simple random data
2026
==================

randomstate/config.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Autogenerated
22

3-
DEF RNG_MOD_NAME='xorshift128'
3+
DEF RS_RNG_MOD_NAME='xorshift128'

randomstate/distributions.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ typedef int bool;
2222
#define M_PI 3.14159265358979323846264338328
2323
#endif
2424

25-
#if defined(PCG_32_RNG)
25+
#if defined(RS_PCG32)
2626
#include "shims/pcg-32/pcg-32-shim.h"
27-
#elif defined(PCG_64_RNG)
27+
#elif defined(RS_PCG64)
2828
#include "shims/pcg-64/pcg-64-shim.h"
29-
#elif defined(RANDOMKIT_RNG)
29+
#elif defined(RS_RANDOMKIT)
3030
#include "shims/random-kit/random-kit-shim.h"
31-
#elif defined(XORSHIFT128_RNG)
31+
#elif defined(RS_XORSHIFT128)
3232
#include "shims/xorshift128/xorshift128-shim.h"
33-
#elif defined(XORSHIFT1024_RNG)
33+
#elif defined(RS_XORSHIFT1024)
3434
#include "shims/xorshift1024/xorshift1024-shim.h"
35-
#elif defined(MRG32K3A_RNG)
35+
#elif defined(RS_MRG32K3A)
3636
#include "shims/mrg32k3a/mrg32k3a-shim.h"
37-
#elif defined(MLFG_1279_861_RNG)
37+
#elif defined(RS_MLFG_1279_861)
3838
#include "shims/mlfg-1279-861/mlfg-1279-861-shim.h"
39-
#elif defined(DSFMT_RNG)
39+
#elif defined(RS_DSFMT)
4040
#include "shims/dSFMT/dSFMT-shim.h"
4141
#else
4242
#error Unknown RNG!!! Unknown RNG!!! Unknown RNG!!!

randomstate/interface.pyx

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,29 @@ from cython_overrides cimport PyFloat_AsDouble, PyInt_AsLong, PyErr_Occurred, Py
2323
np.import_array()
2424

2525
include "config.pxi"
26+
include "defaults.pxi"
2627

27-
IF RNG_MOD_NAME == 'pcg32':
28+
IF RS_RNG_MOD_NAME == 'pcg32':
2829
include "shims/pcg-32/pcg-32.pxi"
29-
IF RNG_MOD_NAME == 'pcg64':
30-
IF PCG128_EMULATED:
30+
IF RS_RNG_MOD_NAME == 'pcg64':
31+
IF RS_PCG128_EMULATED:
3132
include "shims/pcg-64/pcg-64-emulated.pxi"
3233
ELSE:
3334
include "shims/pcg-64/pcg-64.pxi"
34-
IF RNG_MOD_NAME == 'mt19937':
35+
IF RS_RNG_MOD_NAME == 'mt19937':
3536
include "shims/random-kit/random-kit.pxi"
36-
IF RNG_MOD_NAME == 'xorshift128':
37+
IF RS_RNG_MOD_NAME == 'xorshift128':
3738
include "shims/xorshift128/xorshift128.pxi"
38-
IF RNG_MOD_NAME == 'xorshift1024':
39+
IF RS_RNG_MOD_NAME == 'xorshift1024':
3940
include "shims/xorshift1024/xorshift1024.pxi"
40-
IF RNG_MOD_NAME == 'mrg32k3a':
41+
IF RS_RNG_MOD_NAME == 'mrg32k3a':
4142
include "shims/mrg32k3a/mrg32k3a.pxi"
42-
IF RNG_MOD_NAME == 'mlfg_1279_861':
43+
IF RS_RNG_MOD_NAME == 'mlfg_1279_861':
4344
include "shims/mlfg-1279-861/mlfg-1279-861.pxi"
44-
IF RNG_MOD_NAME == 'dsfmt':
45+
IF RS_RNG_MOD_NAME == 'dsfmt':
4546
include "shims/dSFMT/dSFMT.pxi"
4647

47-
IF NORMAL_METHOD == 'inv':
48+
IF RS_NORMAL_METHOD == 'inv':
4849
__normal_method = 'inv'
4950
ELSE:
5051
__normal_method = 'zig'
@@ -139,11 +140,11 @@ cdef class RandomState:
139140
poisson_lam_max = POISSON_LAM_MAX
140141
__MAXSIZE = <uint64_t>sys.maxsize
141142

142-
IF RNG_SEED==1:
143+
IF RS_RNG_SEED==1:
143144
def __init__(self, seed=None):
144145
self.rng_state.rng = <rng_t *>PyArray_malloc_aligned(sizeof(rng_t))
145146
self.rng_state.binomial = &self.binomial_info
146-
IF RNG_MOD_NAME == 'dsfmt':
147+
IF RS_RNG_MOD_NAME == 'dsfmt':
147148
self.rng_state.buffered_uniforms = <double *>PyArray_malloc_aligned(2 * DSFMT_N * sizeof(double))
148149
self.lock = Lock()
149150
self._reset_state_variables()
@@ -158,7 +159,7 @@ cdef class RandomState:
158159

159160
def __dealloc__(self):
160161
PyArray_free_aligned(self.rng_state.rng)
161-
IF RNG_MOD_NAME == 'dsfmt':
162+
IF RS_RNG_MOD_NAME == 'dsfmt':
162163
PyArray_free_aligned(self.rng_state.buffered_uniforms)
163164

164165
# Pickling support:
@@ -169,9 +170,9 @@ cdef class RandomState:
169170
self.set_state(state)
170171

171172
def __reduce__(self):
172-
return (randomstate.prng.__generic_ctor, (RNG_MOD_NAME,), self.get_state())
173+
return (randomstate.prng.__generic_ctor, (RS_RNG_MOD_NAME,), self.get_state())
173174

174-
IF RNG_NAME == 'mt19937':
175+
IF RS_RNG_NAME == 'mt19937':
175176
def seed(self, seed=None):
176177
"""
177178
seed(seed=None)
@@ -212,7 +213,7 @@ cdef class RandomState:
212213
set_seed_by_array(&self.rng_state, <unsigned long *>np.PyArray_DATA(obj), np.PyArray_DIM(obj, 0))
213214
self._reset_state_variables()
214215

215-
ELIF RNG_SEED==1:
216+
ELIF RS_RNG_SEED==1:
216217
def seed(self, val=None):
217218
"""
218219
seed(seed=None)
@@ -272,8 +273,8 @@ cdef class RandomState:
272273
raise ValueError('val < 0')
273274
if inc < 0:
274275
raise ValueError('inc < 0')
275-
IF RNG_NAME == 'pcg64':
276-
IF PCG128_EMULATED:
276+
IF RS_RNG_NAME == 'pcg64':
277+
IF RS_PCG128_EMULATED:
277278
set_seed(&self.rng_state,
278279
pcg128_from_pylong(val),
279280
pcg128_from_pylong(inc))
@@ -292,7 +293,7 @@ cdef class RandomState:
292293
self.rng_state.uinteger = 0
293294
self.rng_state.binomial.has_binomial = 0
294295

295-
IF RNG_ADVANCEABLE:
296+
IF RS_RNG_ADVANCEABLE:
296297
def advance(self, delta):
297298
"""
298299
advance(delta)
@@ -314,8 +315,8 @@ cdef class RandomState:
314315
Advancing the prng state resets any pre-computed random numbers.
315316
This is required to ensure exact reproducibility.
316317
"""
317-
IF RNG_NAME == 'pcg64':
318-
IF PCG128_EMULATED:
318+
IF RS_RNG_NAME == 'pcg64':
319+
IF RS_PCG128_EMULATED:
319320
advance_state(&self.rng_state, pcg128_from_pylong(delta))
320321
ELSE:
321322
advance_state(&self.rng_state, delta)
@@ -326,7 +327,7 @@ cdef class RandomState:
326327
self.rng_state.gauss = 0.0
327328
return None
328329

329-
IF RNG_JUMPABLE:
330+
IF RS_RNG_JUMPABLE:
330331
def jump(self, uint32_t iter = 1):
331332
"""
332333
jump(iter = 1)
@@ -356,7 +357,7 @@ cdef class RandomState:
356357
self.rng_state.gauss = 0.0
357358
return None
358359

359-
IF RNG_NAME == 'mt19937':
360+
IF RS_RNG_NAME == 'mt19937':
360361
def get_state(self, legacy=False):
361362
"""
362363
get_state()
@@ -394,11 +395,11 @@ cdef class RandomState:
394395
component, see the class documentation.
395396
"""
396397
if legacy:
397-
return (RNG_NAME,) \
398+
return (RS_RNG_NAME,) \
398399
+ _get_state(self.rng_state) \
399400
+ (self.rng_state.has_gauss, self.rng_state.gauss)
400401

401-
return {'name': RNG_NAME,
402+
return {'name': RS_RNG_NAME,
402403
'state': _get_state(self.rng_state),
403404
'gauss': {'has_gauss': self.rng_state.has_gauss, 'gauss': self.rng_state.gauss},
404405
'uint32': {'has_uint32': self.rng_state.has_uint32, 'uint32': self.rng_state.uinteger}
@@ -435,7 +436,7 @@ cdef class RandomState:
435436
For information about the specific structure of the PRNG-specific
436437
component, see the class documentation.
437438
"""
438-
return {'name': RNG_NAME,
439+
return {'name': RS_RNG_NAME,
439440
'state': _get_state(self.rng_state),
440441
'gauss': {'has_gauss': self.rng_state.has_gauss, 'gauss': self.rng_state.gauss},
441442
'uint32': {'has_uint32': self.rng_state.has_uint32, 'uint32': self.rng_state.uinteger}
@@ -478,8 +479,8 @@ cdef class RandomState:
478479
For information about the specific structure of the PRNG-specific
479480
component, see the class documentation.
480481
"""
481-
rng_name = RNG_NAME
482-
IF RNG_NAME == 'mt19937':
482+
rng_name = RS_RNG_NAME
483+
IF RS_RNG_NAME == 'mt19937':
483484
if isinstance(state, tuple):
484485
if state[0] != 'MT19937':
485486
raise ValueError('Not a ' + rng_name + ' RNG state')
@@ -4227,7 +4228,7 @@ permutation = _rand.permutation
42274228

42284229
sample = ranf = random = random_sample
42294230

4230-
IF RNG_JUMPABLE:
4231+
IF RS_RNG_JUMPABLE:
42314232
jump = _rand.jump
4232-
IF RNG_ADVANCEABLE:
4233+
IF RS_RNG_ADVANCEABLE:
42334234
advance = _rand.advance

randomstate/setup-single-rng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
with open('config.pxi', 'w') as config:
1616
config.write('# Autogenerated\n\n')
17-
config.write("DEF RNG_MOD_NAME='xorshift128'\n")
17+
config.write("DEF RS_RNG_MOD_NAME='xorshift128'\n")
1818

1919
pwd = getcwd()
2020

randomstate/shims/dSFMT/dSFMT-poly.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
static const char * poly_128 =
2+
"f4dfa6c62049d0776e0bf6f1e953f3aa38abb113df86be024eab3773ad5f2b82ead936022e656dff7e562691c59dd5f7d2"
3+
"566b78d9669002503c4ddb1888a49f32333f515e6c60c4ecd221078ec6f26f0a90f4875067ca1f399a99775037adf90556"
4+
"6e2c7e6b42131420f8f04f112c92621c9b1502f2a8aefad6c667904af62f0d55e02d396902d3b89450103c5ce5fe0408d9"
5+
"7cbb864861b49e4e42048ff3310b48faac55095a7f422eea4aade752f947f947c6be0a0c665bdea099246ab9eff658ea8c"
6+
"a468bf49d0227748367878de06d7bd86ea6708fcac6e252f5f00f04309b2aac3036b64afb39d990427c6c9f03477cc7e93"
7+
"5c43c0e61bc161db8eb15516eee8cb377ecbc1849207990fb6778721b29bfe0d89bfda1b3772fa5b0b1f7ec3daf3605203"
8+
"2285898c6f6396f55010c31f8201b7e2e51d94f920bfe57684c5415cc342cb39a0045d9793d13cf8646096daeb8bb9bfc2"
9+
"0a90de8f2426da8733267a9b9674f32154e8f84a9932223a2ca3c787d0b66df6675febbdfcba2f9cef09c621c57e11098b"
10+
"3289c77397aaae8b104642ffe0c4b75598efbc53745984d68b4d6656cae299ae2be55217a9a02b009ca7be32f47fbe434b"
11+
"ce4914a34d0c9b0085bede9b8a99319c34660d66f0124b5a7714c4bf3cbfec3ee43ed817087168bad80133bebaeeb68cf7"
12+
"929a24d1bb3de831a8340d220906ab04159cf94b21d5ee813bd7c80f10f01b43052af530917513b169254c25d6fcfe6cb4"
13+
"20d6ce92f54886ef6eaf9a5ba35e893ff593834d05ddf28899e42d729c7df3d21ef036020789739366f0c11ec52ff92a0b"
14+
"fd8ba69508e27b20fabb8217bd36b90e5aa918159ac87913bc7b46c04e366c23c92807fbe9c6a407e6a4db0b4fc23c3b6c"
15+
"706b5ca058fe8c190f849f18d16d6b48b5ed760eb202fd566291a799420b9654e08b8118bcbfead8e9dd2fdb9b053e9bdf"
16+
"b665285c78718f726d0b3d6c37e116428ec9ac9db2637259e4e8d6402bbada46c6bdb03985e19a82e9b4e57de1b025a3cb"
17+
"1f850beae7e8da9941655825bce0e89d536b6ee9064865b1a85c185e9fc9cb7f435de13d44773c00eed442a286e4ab807e"
18+
"3cab4dc3441d1b7d2af693812ae8b39652bb8c835fc895d13d6da93541afeadeee450475c29f3b2dfa8ef1c1e2547463b2"
19+
"cc2f0ff7a42ac4dd35e25c4fa030d2d2766fbe9f2d04c1304671747bace2f7dd55142bfa60f8cbc968bfc3d7a342152dc6"
20+
"84a0fb5a32c0962a62b5220ac0f72add9d8b84d6cc76b97d03245e01fc8da3414a49bb4075d3488f29b56dc42ba69e3b58"
21+
"529448c943ecfd98b3784a39d0b8609a8fb945e757f4569f53bd2cf80f7f638acf5b67fe9c560a3b7b0cf7e0398f31aa8b"
22+
"03cf9c62b24296b6d8596b694469a02686c38daa16a1ef86e012d61a2f7de1693a5c00b3685175caec3c67146477eba548"
23+
"30f1d546cb18a553779aa46adb4f2010e33f3def847c7d89b51a8462b227605f6c920fd558a6daf64bc98682e508ae960c"
24+
"0c571870e603ba1fce0c13d53176f353fd319959e13db93eae1359f06e3dd4767c04f824cf34ec7bf8f60161ba1a615db8"
25+
"2852eca9e3869afa711ab9a090660b0dc6cfbea310dda77e02310fbaeacd2636f975838c2dbcdbe9ac2cd85cee28f5e3f0"
26+
"c73abf62f9fa02cd79a7606b7ba855db68a07848b057c3aaf38f1a70086e14616f6f88305a1f9ce6b41378a620d4db3e0e"
27+
"7e1d421590dccaeff86212e232eeb5eb8a8d33a8c9b25ae88f3a7bd5032b4efa68f8af3186a02ffcbf5456f12beccace94"
28+
"c81c360cc4a0dcc642b59f991eec68c59af78139ca60b96d6a18e9535f8995e89bd2cf6a0aef3acffd33d1c0c1b79b6641"
29+
"4a91d9f65b2b4ec65844b96f725d2b4b0c309f3eb9d714e9dd939bbdfd85ce8fb43679aeab13f6c29549949503c9466dbd"
30+
"337c4cdde46d6eacd15f21f4d8fdeaa627a47884c88a9c85f0b731d271a8ea7cb9e04a4a149c23c10f56b3a0476dc77a99"
31+
"9d6e4f813e4b0f805e2a693e2ae4ae0ecc423c9ba5d17b42e691abf83784a582f2b1fd85d1e0a27ba38a500963568b2450"
32+
"363d2c5e3f7b8ba3e5b56e4e9f745a3a710bf2ae233c303068c532ce78ff031e6ab28b705dd94d7db4500909edb5626b8c"
33+
"9bd5ff4f0b4741388f0b91563ee516934c013e901572cba005ac5c535f4f107903be9af7b2793dfb61b5070facbe71eefe"
34+
"1b5600f975c8c38c3a2350d78beadfecb78e981164ae8bc866e732972d3ceef4aac68e15861f9b881d9b51b4edece150bc"
35+
"124b07645defb4202ef5d0e0962db98cae6ed459561c93c74c20bd64362e4f4fffc389a6cd80514604ff22eecc10c9cbc7"
36+
"981d19a8102b24146354c463107c9dc070e29e70df3578022acf72289ef071ab9f9402a544d0399f1b1e5f206b6d46d445"
37+
"f6d612a490e72918e00c853eda8493bef511149e80c9ab56e8b4b8cba3987249f77d060e61760e5792ac321c987c03c260"
38+
"6e9393a7970212992cdbd16448078d5039d4c2c3199714f53278f4f7b1d2e514cf95bdfc078b8bb0db659cb2c3f5cc0289"
39+
"0ea84f05d414c88d2db9e9f8455659b9fa6254405317245fa070d6970cafb4dadb2522b490a5c8e02fe973a8cdbfbfbdbf"
40+
"b01535099ffba3d3896bc4d1189fc570c3e6fdc6469265b8da912772e75dd62ab71be507f700d56cac5e68fd6b57ec1661"
41+
"68ab5258a69625c142a5b1b3519f94be1bde5e51d3bd8ea0c12d5af2fe4615b1b7bd4a96628a4fabc65925ff09718f63bb"
42+
"ebaad98f89bd9543a27b3ff3b5d8bfa89f941a5eb8cc005ccd4a705190e1c9dc6a9f4264e5ee658520a4438e92de854bff"
43+
"c39f8dc7dfbb5de4f14ba63ea16a37d14a7b4610f95b6cffd55e4679b29cedbdf20e7bd16da822fad910c359ee3a68e48a"
44+
"ae6e769b0e291d5d3aa3e2ca9d8d23abe8a1d5349f4991e9300852cc0befb20c2fc0d169306b260763344024f8092cbcc2"
45+
"4c6807363e9fc548a30d5faab3a94b2af0782a2942be80c45d8b0587efd587394ef33c33022436e285806ddffdd32fe363"
46+
"45c3c38ed8d680abeb7a028b44ee6f94d060a14c7019bb6af1f1b5f0a562957d19826d8cc216f9b908c989ccd5415e3525"
47+
"dfe9422ffb5b50b7cc3083dc325544751e5683535d7439d3da2b0bb73bea551dd99e04e0e793804f4774eb6b1daf781d9c"
48+
"aa5128274e599e847862fe309027813d3e4eda0bbeb7201856a5c5d8370e44dabff0bb229c723ba0a6bcf29c44536147de"
49+
"11b7835991018100105bd4329217f7386903fe8e7363cd7b3e893244e245e0a187467664c05b0be1fd429722b9b9a5e319"
50+
"8147fad72776e8a63aab9054fa9d259af0198d088d71d132e6068676a8e9ebb0f616b51ee34aac39c2c2221c7112401727"
51+
"0d75ff4a048363c389e04e9b440ad2032a381ac2cfc54f409caa791e65ee4f5d6cd035008f219b88a803a7382ae447bf65"
52+
"a3df2176b25b3b7b67dabe34decd9a1384dc7a003916ca8fbcb29b3ad6fd8eac5bbbaa3bdfa6c6a3ad9427c4f3ed79fea2"
53+
"6e14c8ce5fa3b4f82c5f7b6d2125916753a7b92ce9b46d45";

randomstate/shims/dSFMT/dSFMT-shim.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "dSFMT-shim.h"
2+
#include "dSFMT-poly.h"
23

34
extern inline uint32_t random_uint32(aug_state* state);
45

@@ -33,4 +34,9 @@ void entropy_init(aug_state* state)
3334
uint32_t seeds[1];
3435
entropy_fill((void*) seeds, sizeof(seeds));
3536
set_seed(state, seeds[0]);
37+
}
38+
39+
void jump_state(aug_state* state)
40+
{
41+
dSFMT_jump(state->rng, poly_128);
3642
}

randomstate/shims/dSFMT/dSFMT-shim.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
#include "../../src/common/binomial.h"
1111
#include "../../src/common/entropy.h"
12+
#include "../../src/dSFMT/dSFMT-jump.h"
1213
#include "../../src/dSFMT/dSFMT.h"
1314

15+
1416
typedef struct s_aug_state {
1517
dsfmt_t *rng;
1618
binomial_t *binomial;
@@ -69,3 +71,4 @@ extern void set_seed_by_array(aug_state* state, uint32_t init_key[], int key_len
6971

7072
extern void set_seed(aug_state* state, uint32_t seed);
7173

74+
extern void jump_state(aug_state* state);

randomstate/shims/dSFMT/dSFMT.pxi

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
DEF RNG_NAME = 'dSFMT'
2-
DEF RNG_ADVANCEABLE = 0
3-
DEF RNG_SEED = 1
4-
DEF RNG_JUMPABLE = 0
5-
DEF RNG_STATE_LEN = 4
6-
DEF NORMAL_METHOD = 'zig'
1+
DEF RS_RNG_NAME = 'dSFMT'
2+
DEF RS_RNG_JUMPABLE = 1
73
DEF DSFMT_MEXP = 19937
84
DEF DSFMT_N = 191 # ((DSFMT_MEXP - 128) / 104 + 1)
95
DEF DSFMT_N_PLUS_1 = 192 # DSFMT_N + 1
@@ -43,6 +39,9 @@ cdef extern from "distributions.h":
4339

4440
cdef void set_seed_by_array(aug_state* state, uint32_t init_key[], int key_length)
4541

42+
cdef void jump_state(aug_state* state)
43+
44+
4645
ctypedef dsfmt_t rng_t
4746

4847
cdef object _get_state(aug_state state):
@@ -85,8 +84,8 @@ RandomState(seed=None)
8584
Container for the SIMD-based Mersenne Twister pseudo-random number generator.
8685
8786
``dSFMT.RandomState`` exposes a number of methods for generating random
88-
numbers drawn from a variety of probability distributions. In addition to the
89-
distribution-specific arguments, each method takes a keyword argument
87+
numbers drawn from a variety of probability distributions [1]_ . In addition
88+
to the distribution-specific arguments, each method takes a keyword argument
9089
`size` that defaults to ``None``. If `size` is ``None``, then a single
9190
value is generated and returned. If `size` is an integer, then a 1-D
9291
array filled with generated values is returned. If `size` is a tuple,
@@ -118,4 +117,28 @@ pseudo-random number generator with a number of methods that are similar
118117
to the ones available in `RandomState`. `RandomState`, besides being
119118
NumPy-aware, has the advantage that it provides a much larger number
120119
of probability distributions to choose from.
120+
121+
**Parallel Features**
122+
123+
``dsfmt.RandomState`` can be used in parallel applications by
124+
calling the method ``jump`` which advances the the state as-if :math:`2^{128}`
125+
random numbers have been generated [2]_. This allow the original sequence to
126+
be split so that distinct segments can be used on each worker process. All
127+
generators should be initialized with the same seed to ensure that the
128+
segments come from the same sequence.
129+
130+
>>> from randomstate.entropy import random_entropy
131+
>>> import randomstate.prng.dsfmt as rnd
132+
>>> seed = random_entropy()
133+
>>> rs = [rnd.RandomState(seed) for _ in range(10)]
134+
# Advance rs[i] by i jumps
135+
>>> for i in range(10):
136+
rs[i].jump(i)
137+
138+
.. [1] Mutsuo Saito and Makoto Matsumoto, "SIMD-oriented Fast Mersenne
139+
Twister: a 128-bit Pseudorandom Number Generator." Monte Carlo
140+
and Quasi-Monte Carlo Methods 2006, Springer, pp. 607 -- 622, 2008.
141+
.. [2] Hiroshi Haramoto, Makoto Matsumoto, and Pierre L'Ecuyer, "A Fast
142+
Jump Ahead Algorithm for Linear Recurrences in a Polynomial Space",
143+
Sequences and Their Applications - SETA, 290--298, 2008.
121144
"""

randomstate/shims/mlfg-1279-861/mlfg-1279-861.pxi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
DEF RNG_NAME = 'mlfg-1279-861'
2-
DEF RNG_ADVANCEABLE = 0
3-
DEF RNG_JUMPABLE = 0
4-
DEF RNG_STATE_LEN = 4
5-
DEF RNG_SEED = 1
6-
DEF NORMAL_METHOD = 'zig'
7-
1+
DEF RS_RNG_NAME = 'mlfg-1279-861'
82
DEF MLFG_STATE_LEN = 1279
93

104
cdef extern from "distributions.h":

0 commit comments

Comments
 (0)