|
| 1 | +MCG31 brng |
| 2 | +========== |
| 3 | + |
| 4 | +The 31-bit multiplicative congruential pseudorandom number generator MCG(1132489760, 2**31 -1) can be |
| 5 | +initialized with either an integral seed, a list of integral seeds, or automatically. |
| 6 | + |
| 7 | +.. code-block:: python |
| 8 | + :caption: Construction for MCG31 basic random number generator with scalar seed |
| 9 | +
|
| 10 | + import mkl_random |
| 11 | + rs = mkl_random.RandomState(1234, brng="MCG31") |
| 12 | +
|
| 13 | + # Use random state instance to generate 1000 random numbers from |
| 14 | + # Uniform(0, 1) distribution |
| 15 | + esample = rs.uniform(0, 1, size=1000) |
| 16 | +
|
| 17 | +.. code-block:: python |
| 18 | + :caption: Construction for MCG31 basic random number generator with vector seed |
| 19 | +
|
| 20 | + import mkl_random |
| 21 | + rs_vec = mkl_random.RandomState([1234, 567, 89, 0], brng="MCG31") |
| 22 | +
|
| 23 | + # Use random state instance to generate 1000 random numbers from |
| 24 | + # Gamma(3, 1) distibution |
| 25 | + gsample = rs_vec.gamma(3, 1, size=1000) |
| 26 | +
|
| 27 | +When seed is not specified, the generator is initialized using system clock, e.g.: |
| 28 | +
|
| 29 | +.. code-block:: python |
| 30 | + :caption: Construction for MCG31 basic random number generator automatic seed |
| 31 | +
|
| 32 | + import mkl_random |
| 33 | + rs_def = mkl_random.RandomState(brng="MCG31") |
| 34 | +
|
| 35 | + # Use random state instance to generate 1000 random numbers |
| 36 | + # from discrete uniform distribution [1, 6] |
| 37 | + isample = rs_def.randint(1, 6 + 1, size=1000) |
0 commit comments