RandomKit
RandomKit copied to clipboard
Distributions
RandomKit should be able to generate random floating-point values with various distributions.
They should:
- Not add too much compile time
- Be modular
- Be fast
Rust's rand crate implements this via separate types.
@phimage, do you have any implementation suggestions?
I am not familiar with rust, packaging, types, etc... but I can read some code https://github.com/rust-lang-nursery/rand/tree/master/src/distributions and see mention of zigurat, exponential distrib, etc...
Be fast
There is more than one approximation method to generate number with random distributions
I use polar form of the Box-Muller transformation for gaussian
- https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
there is others method like I mention in my code here
(others methods The Ratio method[50], The ziggurat algorithm)
I don`t study this method, but I think ziggurat is faster
Be modular
My implementation https://github.com/nvzqz/RandomKit/pull/26 was protocol-oriented, like RandomKit
Not add too much compile time
It seems that my implementation add too much compile time for you https://github.com/nvzqz/RandomKit/issues/29
So one negative thing that struck out to me with the previous implementation was that it added methods to types implementing the distribution protocol that were outside of RandomKit's scope. In order to avoid this, we could have only the methods required for the protocols. Then implement the protocols individually for Double
and Float
.
There doesn't seem to be any current swift3/4 compilable code that can do Weibull distribution. https://github.com/aidangomez/RandKit/blob/master/Source/Distributions/Continuous/Weibull.swift
Eric's implementation seems to come undone with renaming of RandomWithinClosedRange https://github.com/phimage/RandomDistributionKit/issues/1 his library depends on this library -
it would be neat if this was all self contained.