2016-11-10 10 views
1

PCG RNGのinc変数のポイントは何ですか? <a href="http://www.pcg-random.org/download.html" rel="nofollow noreferrer">this code</a>から

// *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 for max ILP 
    uint32_t xorshifted = ((oldstate >> 18u)^oldstate) >> 27u; 
    uint32_t rot = oldstate >> 59u; 
    return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); 
} 

rng->incのポイントは何ですか?私が見る限り、それは決して書かれていません。

答えて

1

正確には、シードストリームセレクタだと思います。

// pcg32_srandom(initstate, initseq) 
// pcg32_srandom_r(rng, initstate, initseq): 
//  Seed the rng. Specified in two parts, state initializer and a 
//  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); 
} 

the PCG websiteの流れについての詳細はあります:code on GitHub、特にpcg32_srandom_r機能を見てみましょう。

+0

ああ、私は見るので、あなたはいくつかの異なるPRNシーケンスが欲しいですが、それらを#1、#2、#3などとして参照したいと思っています。ありがとう! – Timmmm

関連する問題