The toy generator¶
The 8-bit permuted congruential generator of Appendix C.
simstreams.pcg8 ¶
A toy 8-bit permuted congruential generator (Appendix C).
PCG8 advances an 8-bit linear congruential state and then permutes the old state with an xorshift and a rotation chosen by the state's top bits. It has only 256 states, so its entire cycle can be enumerated, which is what makes it useful for seeing how the full PCG64 generator works.
PCG8 ¶
Toy 8-bit PCG generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int
|
Initial state, reduced to 8 bits. |
0
|
inc
|
int
|
Increment of the congruential step. Must be odd. |
1
|
mult
|
int
|
Multiplier of the congruential step. |
141
|
Source code in src/simstreams/pcg8.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
random ¶
random()
Advance the state and return the next 8-bit output.
Source code in src/simstreams/pcg8.py
37 38 39 40 41 42 43 | |
rotr8 ¶
rotr8(x, r)
Rotate the 8-bit value x right by r bits.
Source code in src/simstreams/pcg8.py
10 11 12 13 | |