<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKGaussianDistribution",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKGaussianDistribution"
  },
  "title" : "GKGaussianDistribution"
}
-->

# GKGaussianDistribution

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

```
class GKGaussianDistribution
```

## 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](https://developer.apple.com/library/archive/documentation/Security/Conceptual/cryptoservices/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011172).

![](images/com.apple.gameplaykit/media-2133123@2x.png)

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 [`GKRandomDistribution`](/documentation/GameplayKit/GKRandomDistribution).

A Gaussian distribution is characterized by its [`mean`](/documentation/GameplayKit/GKGaussianDistribution/mean) and [`deviation`](/documentation/GameplayKit/GKGaussianDistribution/deviation) properties. The [`mean`](/documentation/GameplayKit/GKGaussianDistribution/mean) value (also called the *median* or *expected value*) is the value at the center of the distribution (halfway between its [`lowestValue`](/documentation/GameplayKit/GKRandomDistribution/lowestValue) and [`highestValue`](/documentation/GameplayKit/GKRandomDistribution/highestValue) 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`](/documentation/GameplayKit/GKGaussianDistribution/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.

```swift
let random = GKRandomSource()
let dice3d6 = GKGaussianDistribution(randomSource: random, lowestValue: 3, highestValue: 18)
// Roll the dice...
let diceRoll = dice3d6.nextInt()
```

For more information on choosing and using randomizers in GameplayKit, read [Randomization](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/RandomSources.html#//apple_ref/doc/uid/TP40015172-CH9) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Creating a Random Distribution

[`-  initWithRandomSource:lowestValue:highestValue:`](/documentation/GameplayKit/GKGaussianDistribution/init(randomSource:lowestValue:highestValue:))

Initializes a Gaussian random distribution with the specified lower and upper bounds, using the specified source randomizer.

[`-  initWithRandomSource:mean:deviation:`](/documentation/GameplayKit/GKGaussianDistribution/init(randomSource:mean:deviation:))

Initializes a Gaussian random distribution with the specified mean and deviation, using the specified source randomizer.

### Working with Characteristics of a Distribution

[`mean`](/documentation/GameplayKit/GKGaussianDistribution/mean)

The mean value of the distribution (also called the *expected value* or *median*).

[`deviation`](/documentation/GameplayKit/GKGaussianDistribution/deviation)

The standard deviation of the distribution (also called *sigma*).

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`GKRandom`](/documentation/GameplayKit/GKRandom)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

### Inherits From

[`GKRandomDistribution`](/documentation/GameplayKit/GKRandomDistribution)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)