A generator for random numbers that follow a *Gaussian distribution* (also known as a *normal distribution*) across multiple samplings.

SDKs

- iOS 9.0+
- macOS 10.11+
- tvOS 9.0+

Framework

- Gameplay
Kit

## Overview

Important

The randomization services provided in GameplayKit are suitable for reliably creating deterministic, pseudorandom gameplay mechanics, but are not cryptographically robust. For cryptography, obfuscation, or cipher uses, use the Security framework, described in Cryptographic Services Guide.

In a Gaussian distribution, random samplings are most likely to result in a value near the center of the distribution, and have reduced probability of producing higher or lower values. To generate random numbers with a Gaussian distribution, use the methods defined by its superclass `GKRandom`

.

A Gaussian distribution is characterized by its `mean`

and `deviation`

properties. The `mean`

value (also called the *median* or *expected value*) is the value at the center of the distribution (halfway between its `lowest`

and `highest`

properties), and the most likely value to result from a random sampling. The farther any other value is from the mean, the less likely that value is to result from a random sampling. The `deviation`

value (also called *standard deviation* or *sigma*) characterizes those probabilities: 68.27% of values generated by the distribution are within one deviation of the mean, 95% of generated values are within two deviations, and 100% of generated values are within three deviations.

Note

In the standard mathematical model of a Gaussian distribution, 99.7% of generated values are within three deviations of the mean and the distribution’s range is infinite. GameplayKit discards the extremely unlikely values more than three deviations from the mean in order to set finite limits on the distribution’s range.

Gaussian distributions appear in many natural phenomena that you might model in a game. For example, the following code creates a distribution whose random number generation is equivalent to rolling three six-sided dice (also called *3d6*) and summing the results.

For more information on choosing and using randomizers in GameplayKit, read Randomization in GameplayKit Programming Guide.