Skip to content

Collection of functions for generating psuedorandom variables from various distributions

License

Notifications You must be signed in to change notification settings

SebastianOsinski/SORandom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#SORandom

Version License Platform

SORandom is collection of pseudorandom generators from various statistical distributions and functions for pseudorandom array sampling.

Installation

SORandom is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SORandom"

Author

Sebastian Osiński, [email protected]

License

SORandom is available under the MIT license. See the LICENSE file for more info.

##Available psuedorandom generators:

##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)

About

Collection of functions for generating psuedorandom variables from various distributions

Resources

License

Stars

Watchers

Forks

Packages

No packages published