#SORandom
SORandom is collection of pseudorandom generators from various statistical distributions and functions for pseudorandom array sampling.
SORandom is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SORandom"
Sebastian Osiński, seb.osinski@gmail.com
SORandom is available under the MIT license. See the LICENSE file for more info.
##Available psuedorandom generators:
- Discrete distributions:
- Continuous distributions:
##Sampling functions:
- Sampling with replacement
- Sampling without replacement
- Sampling with replacement with given weights
##How to use it?
import SORandom
//Single pseudorandom normal variable
//with mean 0 and standard deviation 1
let x = randNormal(0, 1)
//Array of pseudorandom independent normal variables
//with mean 0 and standard deviation 1 and length 10
let sample = randNormals(0, 1, 10)
//Sampling from array:
//with replacement
let numbers = [10, 11, 45, 1, 0, 4]
let bootstrapSample = sampleWithReplacement(numbers, 10)
//without replacement
let names = ["John", "Bob", "Anna", "Alice", "Chris", "Luke"]
let usersOrder = sampleWithoutReplacement(names, 4)
//with given weights
let letters = ["a", "b", "c", "d", "e"]
let probabilities = [0.5, 0.05, 0.05, 0.1, 0.3]
let randomLetters = sampleWithWeights(letters, probabilities, 10)