Code Monkey home page Code Monkey logo

granderl's Introduction

What is this?

Experiments in fast "random" number generation for Erlang; though they have the same interface as rand:uniform/1, think of them more like phash2/2 with a timestamp -- not really random, but fast (hopefully).

Specifically, some of the PRNGs here use methods that are known to be biased. They are not suitably for any application which assumes uniformity. They are also not guaranteed to produce uncorrelated streams when used in parallel.

Building

Use rebar3. To override the default implementation choice, you can set the IMPLEMENTATION environment variable:

$ IMPLEMENTATION=rdrand rebar3 compile

Interface

All functions take an integer between 1 and 232-1, and return an integer between 1 and the supplied integer, like rand:uniform/1.

granderl:

uniform(N :: 1..4294967295) -> 1..4294967295

Implementations

rdrand

32-bits of RDRAND.

xorshift

Marsaglia's original xorshift (with no multiplies), keeping state in thread-local storage. Initialized on first call.

pcg32

PCG, TLS.

msws

Middle Square Weyl Sequence, keeping state in thread-local storage. Initialized on first call.

References

Fog, Agner. "Pseudo-Random Number Generators for Vector Processors and Multicore Processors." Journal of Modern Applied Statistical Methods 14.1 (2015): 308-334.

Marsaglia, George. "Xorshift RNGs." Journal of Statistical Software 8.14 (2003): 1-6.

O'Neill, M.E. "PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation".

Widynsky, Bernard. "Middle Square Weyl Sequence RNG".

License

Because the pcg32 code is derived from Apache-licensed code (see c_src/pcg32.c), this package is also Apache licensed.

granderl's People

Contributors

tokenrove avatar lpgauth avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.