Any RandomNumberGenerator gets uniform: Uniform and normal: Normal.
Uniform and Normal have several next functions.
Example
// Get random float number from uniform distribution [10, 20)
let float: Float = Random.default.uniform.next(in: 10..<20)
/// Get random double number from normal distribution N(1, 3^2)
let double: Double = Random.default.normal.next(mu: 1, sigma: 3)
RNGExtension
Swift exntension for
RandomNumberGenerator.Description
Any
RandomNumberGeneratorgetsuniform: Uniformandnormal: Normal.UniformandNormalhave severalnextfunctions.Example
Installation
Add the following setting to your
Package.swift.