random - What is the point of the inc variable in the PCG RNG? -
from this code:
// *really* minimal pcg32 code / (c) 2014 m.e. o'neill / pcg-random.org // licensed under apache license 2.0 (no warranty, etc. see website) typedef struct { uint64_t state; uint64_t inc; } pcg32_random_t; uint32_t pcg32_random_r(pcg32_random_t* rng) { uint64_t oldstate = rng->state; // advance internal state rng->state = oldstate * 6364136223846793005ull + (rng->inc|1); // calculate output function (xsh rr), uses old state max ilp uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u; uint32_t rot = oldstate >> 59u; return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); }
what point of rng->inc
? never written far can see.
i think it’s seed – stream selector, precise. take @ code on github, pcg32_srandom_r
function:
// pcg32_srandom(initstate, initseq) // pcg32_srandom_r(rng, initstate, initseq): // seed rng. specified in 2 parts, state initializer , // sequence selection constant (a.k.a. stream id) void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, uint64_t initseq) { rng->state = 0u; rng->inc = (initseq << 1u) | 1u; pcg32_random_r(rng); rng->state += initstate; pcg32_random_r(rng); }
there’s more streams on the pcg website.
Comments
Post a Comment