This site works best with JavaScript enabled!

Description: Random Generator - YES / NO

Random Generator Yes No

In this article the algorithm of the "YES / NO" generator is described. The random generator randomly generates the answer Yes or No. If you are unsure and need an oracle, then this site will help you. With the cryptographically safe random generator you do not have to make any decisions by yourself.

Random generator "YES / NO"

Click here to go to the random generator described below.

What is randomness?

Randomness is an event for which there is no causal explanation. This means that the result of a random generator may not be predictable or computable. This, however, contradicts the laws of each computer. In other words, a computer can not produce absolutely random numbers without additional peripherals. In this case we call it pseudo-random numbers. In general, you can philosophize about at which point you can actually speak about randomness.

How are the random answers YES / NO generated?

Theoretically, three different mechanisms for generating pseudo-random numbers are used in this generator, but two of them are only used to generate the binary string in the background.

Random generator 1 and 2 for binary string

The purpose of the binary string is on the one hand the better optics and on the other hand the fact that the user can ensure that a new random value has actually been generated.

Depending on whether JavaScript is enabled or disabled, the binary string is generated in different ways. For the server-side generation of the binary string (with JavaScript disabled) the PHP functions mt_rand() and decbin() are used. The first function generates the actually random number and the second one converts the decimal number into a binary number. In principle, the following algorithm is used:

$random_string = "";
while(strlen($random_string) < PREFERRED_LENGTH) $random_string .= decbin(mt_rand(NUMBER1, NUMBER2));

In the case of a client-side generation of the random binary string (with JavaScript enabled), a modified Fisher-Yates shuffle is applied:

var string = "010010101010010101010101010110101010101001011010";
var n = string.length;

for(var i = n - 1; i > 0; i--) {
	var j = Math.floor(Math.random() * (i + 1));
	var tmp = string[i];
	string[i] = string[j];
	string[j] = tmp;

Random generator 3 for random answer

The previous random number generators produce relatively good random numbers, which, however, can further be improved. The random answer is therefore always generated on server-side with the PHP function random_int(), which generates cryptographically secure pseudo-random numbers:

if((bool)random_int(0, 1)) $random_answer = "YES";
else $random_answer = "NO";
Share this page
Posted on 20.11.2016 | Last modified on 24.05.2018