DiscreteDistribution

public protocol DiscreteDistribution

Protocol for discrete distributions.

Defines the quantile() method that must be implemented.

  • Undocumented

    Declaration

    Swift

    func quantile(_ p: Double) -> Int
  • random(using:) Extension method

    Single discrete random value using a user-provided random number generator

    Declaration

    Swift

    public func random<T>(using generator: inout T) -> Int where T : RandomNumberGenerator

    Parameters

    using

    A random number generator

    Return Value

    A random number from the distribution represented by the instance

  • random() Extension method

    Single discrete random value using the system random number generator

    Declaration

    Swift

    public func random() -> Int

    Return Value

    A random number from the distribution represented by the instance

  • random(_:) Extension method

    Array of discrete random values

    Complexity

    O(n)

    Declaration

    Swift

    public func random(_ n: Int) -> [Int]

    Parameters

    n

    number of values to produce