What is the difference between a random generator seed and a state?

I saw a C ++ program accepting a seed and state for customization std::default_random_engine, which is typedef before std::linear_congruential_engine(at least on my system). The method is seed()used to set the initial seed and operator>>for the state.

I know the principle of generating random number generators (RNGs), but I used it interchangeably with its state.

+4
source share
4 answers

Disclaimer: I am not an expert regarding the theoretical aspect of random number generators, most of the content below is actually derived from the C ++ standard itself.

X i - - () , :

  • , X + 1= TA (X i);
  • "", GA (X i).

S - , X 0.

(. ), ( ), .

++ Mersenne Twister , ... Mersenne Twister, ( ).


, :

A , :

X + 1= TA (X i) = (a. X i + c) mod m

a, c m - . :

  • - X i;
  • - X 0;

... k, X i= k.

, . ++ 11 Mersenne Twister (MT).

, , , ++ draft , :

  • MT- X i= (X i, 0, X i, 1,...);
  • MT ( ) ;

... k, "" 1 X 0 k, X 0, , k.

1 , , , , ().

+1

- , , - . , , - (, , ), , , .

+6

() PRNG, () , , (, ) . , .

operator>> .

() , , .

+2

. , . . . , ( ), ( ) , "" . , "" , , "" . , , , .

0
source

Source: https://habr.com/ru/post/1683925/


All Articles