Using one random mechanism for multiple distributions in C ++ 11

I am using C ++ 11 with a new header <random>in my application and in the same class in different methods I need a different random number with different distributions. I simply placed the random engine std::default_random_engineas a member of the class, ran it in the class constructor with the help, std::random_deviceand used it for different distributions in my methods. It's okay to use a random engine this way or I have to declare different mechanisms for each distribution you use.

+8
source share
4 answers

This is normal.

Reasons for rejecting the generator:

  • Threading (standard RNG implementations are not thread safe)
  • :

    ( / ) , , , , RNG, RNG .

+6

, .

: (, x y), . (noise())

while(simulating)
    x = x + noise()
    y = y + noise()

x y , , , , , , . , , .

. sehe .

+4

. , , (2 ^ 19937 -), . , , , 3 , 1/3 .

, . , , ++ 11, , , , . .

+1

MosteM . , , . - , . , , , : , A, B (0,1), A aA + sqrt (1-a * * 2) B (0,1) a.

EDIT: ++ 11, .

+1

All Articles