nvzqz/RandomKit

Distributions

nvzqz opened this issue · 4 comments

nvzqz commented

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.

nvzqz commented

@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

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 #26 was protocol-oriented, like RandomKit

Not add too much compile time

It seems that my implementation add too much compile time for you #29

nvzqz commented

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

325px-weibull_pdf svg

Eric's implementation seems to come undone with renaming of RandomWithinClosedRange
phimage/RandomDistributionKit#1
his library depends on this library -

it would be neat if this was all self contained.