Testing if rand is really random | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
0

# Testing if rand is really random

What would be a good algorithm to show whether a list of values (eg returned by rand() ) are random?

25th Dec 2016, 5:27 PM
ifl
5 ответов
0
yes sure Vladislav. but it does not answer the initial question. So how could we write a program that proves or disproves that the list of numbers returned by rand is likely to be random or not?
25th Dec 2016, 5:37 PM
ifl
0
Remove srand() to prove that at each program launching it generates the same sequence And the source of rand https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=stdlib/rand_r.c;hb=HEAD
25th Dec 2016, 5:46 PM
0
sure... but lets say we keep srand with a reasonable seed. What sort of program would show that the list of values returned by rand are random and not biased in some way?
25th Dec 2016, 5:51 PM
ifl
0
Generated values are random for us and we can see no logical sequence. The algorithm uses overflow so.. Yes, it's random Example is in the 1st answer
25th Dec 2016, 6:01 PM