How do I generate random numbers for a genetic algorithm?

I am writing a genetic algorithm to solve the game Master Mind. I have done a lot of research on the best approaches, and it is incredibly important to have a diverse population. I am trying to determine how to get really good random numbers in C ++. I did srand(time(NULL))at the beginning of my program to set the seed, then I just used rand(). What would I like to know how random this really is? Is that pretty good? Are there other libraries for random numbers?

I know that number theory and randomness are a very difficult question; Do you have any pointers when writing your own version rand()?

+4
source share
2 answers

For cryptography, you need very strong properties for your random numbers. Most of the literature focuses on such requirements. A typical solution would be to plant SHA-256 iterated applications using environmental noise (hard disk delays, network packets, mouse movements, RDRAND, HAVEGE, ...).

- . , . - , , ( , , 70- 80- , , - ). Mersenne Twister . ++: . std:: mt19937.

+5

rand() . LCG , , . , - . , .

, <random> Mersenne Twister.

PCG. , <random>.

+1

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


All Articles