Check out this question:
Swift probability of random number being selected?
The top answer suggests to use a switch statement, which does the job. However, i
This seems like a good opportunity for a shameless plug to my small library, swiftstats: https://github.com/r0fls/swiftstats
For example, this would generate 3 random variables from a normal distribution with mean 0 and variance 1:
import SwiftStats
let n = SwiftStats.Distributions.Normal(0, 1.0)
print(n.random())
Supported distributions include: normal, exponential, binomial, etc...
It also supports fitting sample data to a given distribution, using the Maximum Likelihood Estimator for the distribution.
See the project readme for more info.