On this page the algorithm of the generator "Form Groups" is described. In this random generator you can enter several names from which groups of the desired size are formed randomly. For example, you can form teams for various games with this generator.

##### Table of contents

## Random generator "Form Groups"

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 groups formed?

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

How these random generators work, is explained here in detail.

### Random generator 3 for group generation

The previous random number generators produce relatively good random numbers, which, however, can further be improved. The groups are therefore always formed on server-side with the PHP function random_int(), which generates cryptographically secure pseudo-random numbers. If the **number of groups** is given, then the groups are formed as follows:

// The array $names contains all names // Until all names have been selected while($number_names > 0) { // For all groups for($g = 1; $g <= $number_groups && $number_names > 0; $g++) { $index = random_int(0, $number_names - 1); $random_groups[$g][] = $names[$index]; unset($names[$index]); // Delete entry $names = array_values($names); // Reset indexes $number_names--; } }

If not the number of groups, but the **number of persons per group** is given, then the algorithm looks like this:

// The array $names contains all names // Until all names have been selected for($g = 1; $number_names > 0; $g++) { // As long as the group is not full for($i = 1; $i <= $number_persons_per_group && $number_names > 0; $i++) { $index = random_int(0, $number_names - 1); $random_groups[$g][] = $names[$index]; unset($names[$index]); // Delete entry $names = array_values($names); // Reset indexes $number_names--; } }