Giter Club home page Giter Club logo

mir-random's Introduction

Gitter Bountysource

Circle CI Build Status Build status

Dub version Dub downloads License

mir-random

Professional Random Number Generators

Documentation: http://docs.random.dlang.io/latest/index.html

import std.range, std.stdio;

import mir.random;
import mir.random.variable: NormalVariable;
import mir.random.algorithm: randomRange;

auto rng = Random(unpredictableSeed);        // Engines are allocated on stack or global
auto sample = rng                            // Engines are passed by reference to algorithms
    .randomRange(NormalVariable!double(0, 1))// Random variables are passed by value
    .take(1000)                              // Fix sample length to 1000 elements (Input Range API)
    .array;                                  // Allocates memory and performs computation

writeln(sample);                             

Comparison with Phobos

  • Does not depend on DRuntime (Better C concept)
random (new implementation and API)
  • Mir Random rand!float/rand!double/rand!real generates saturated real random numbers in (-1, 1). For example, rand!real can produce more then 2^78 unique numbers. In other hand, std.random.uniform01!real produces less then 2^31 unique numbers with default Engine.
  • Mir Random fixes Phobos integer underflow bugs.
  • Addition optization was added for enumerated types.
ramdom.variable (new)
  • Uniform
  • Exponential
  • Gamma
  • Normal
  • Cauchy
  • ...
random.algorithm (new)
  • Range API adaptors
random.engine.* (fixed, reworked)
  • opCall API instead of range interface is used (similar to C++)
  • No default and copy constructors are allowed for generators.
  • @RandomEngine UDA is used for for Engines instead of a enum flag.
  • unpredictableSeed has not state, returns size_t
  • Any unsigned generators are allowed.
  • min proporty was removed. Any integer generator can normalize its minimum down to zero.
  • 64-bit Mt19937 initialization is fixed
  • 64-bit Mt19937 is default for 64-bit targets
  • [WIP] additional Engines, see https://github.com/libmir/mir-random/pulls

mir-random's People

Contributors

9il avatar

Watchers

James Cloos avatar  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.