### Using Stockfish as a true random number generator, possible?

Posted:

**Mon Mar 30, 2015 3:12 am**Hello people,

I would like to know whether it's possible to use Stockfish as a

What I have done:

1)I ran the command "stockfish bench 32 2 16" 500 times. That is, let Stockfish run the bench command (analyses 37 positions) with 32 Mb of hash tables, 2 threads and up to depth 16.

2)Collected the output "Total nodes" and the "time taken".

3)Using a Python code for fun I ran a correlation test between time taken and total nodes searched. The correlation was about 0.70 with an extremely low p-value (I don't remember exactly but lesser than 10^-12.)

So that there is some linear direct correlation between the time taken to complete such a bench command and the total searched node number, with extremely high probability.

4)Using Maxima software, I checked with the Shapiro-Wilk test if the data has a Gaussian distribution and the result is that it has, with a high probability: the Kendall's W was over 0.99 while the p-value was around 0.27.

At that point I wasn't 100% sure whether true random numbers could have a Gaussian distribution but I thought that probably yes.

5)Using R programming language and its library/package "randtests", I applied the Bartels ratio test to check whether the data "total nodes searched" would pass a true random test, which was my main goal.

Null hypothesis: The data is random.

Alternative hypothesis: The data is not random.

The result is that it did pass it:
The p-value is greater than 0.01 and 0.05 so that the data that I've got is likely if the null hypothesis is true.

As a sidenote, here's a graph of trial number vs nodes searched: https://i.imgur.com/Tt2nVYN.png.

So, did I goof somewhere? Was my test lucky to pass the Bartels ratio test?

More precisely, theoretically, is it really impossible to produce true random numbers from Stockfish or a chess engine in general?

When using more than one thread I think that the total nodes searched for a fixed depth depends on the speed of the processors which depends on the temperature of the processors which has random fluctuations. So I would tend to think that indeed it's possible to produce truly random numbers out of a chess engine.

Thank you.

I would like to know whether it's possible to use Stockfish as a

**true**random number generator when using at least 2 threads. I've heard that there is randomness involved when using more than 1 thread but at the same time I've been told that it would be impossible to produce truly random numbers based off a chess engine.What I have done:

1)I ran the command "stockfish bench 32 2 16" 500 times. That is, let Stockfish run the bench command (analyses 37 positions) with 32 Mb of hash tables, 2 threads and up to depth 16.

2)Collected the output "Total nodes" and the "time taken".

3)Using a Python code for fun I ran a correlation test between time taken and total nodes searched. The correlation was about 0.70 with an extremely low p-value (I don't remember exactly but lesser than 10^-12.)

So that there is some linear direct correlation between the time taken to complete such a bench command and the total searched node number, with extremely high probability.

4)Using Maxima software, I checked with the Shapiro-Wilk test if the data has a Gaussian distribution and the result is that it has, with a high probability: the Kendall's W was over 0.99 while the p-value was around 0.27.

At that point I wasn't 100% sure whether true random numbers could have a Gaussian distribution but I thought that probably yes.

5)Using R programming language and its library/package "randtests", I applied the Bartels ratio test to check whether the data "total nodes searched" would pass a true random test, which was my main goal.

Null hypothesis: The data is random.

Alternative hypothesis: The data is not random.

The result is that it did pass it:

Code: Select all

```
statistic = -0.7462, n = 500, p-value = 0.4555
alternative hypothesis: nonrandomness
```

As a sidenote, here's a graph of trial number vs nodes searched: https://i.imgur.com/Tt2nVYN.png.

So, did I goof somewhere? Was my test lucky to pass the Bartels ratio test?

More precisely, theoretically, is it really impossible to produce true random numbers from Stockfish or a chess engine in general?

When using more than one thread I think that the total nodes searched for a fixed depth depends on the speed of the processors which depends on the temperature of the processors which has random fluctuations. So I would tend to think that indeed it's possible to produce truly random numbers out of a chess engine.

Thank you.