Contents

GKRandomDistribution

A generator for random numbers that fall within a specific range and that exhibit a specific distribution over multiple samplings.

Declaration

class GKRandomDistribution

Overview

You choose the algorithm that randomizes source values for a distribution by initializing it with an instance of any class that implements the GKRandom protocol, such as a basic random source (a subclass of GKRandomSource) or another random distribution. The GKRandomDistribution class itself implements a uniform distribution—for more specialized distributions use one of the subclasses GKGaussianDistribution and GKShuffledDistribution.

In a uniform distribution, the probability of generating any number in a specified range (between the values of the distribution’s lowestValue and highestValue properties) is approximately equal. In other words, there is no bias toward any possible outcome. To generate random numbers in this range, use the methods from the GKRandom protocol listed in Generating Random Numbers below.

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

Topics

Creating a Random Distribution

Creating Specific Random Distributions

Generating Random Numbers

Working with Characteristics of a Distribution

See Also

Randomization