Giter Club home page Giter Club logo

mt19937ar-lua's Introduction

mt19937ar-lua

Mersenne Twister RNG for pure Lua 5.1

mt19937ar.lua, a conversion of the Jan 26 2002 version of mt19937ar.c

ref: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html

Copyright (C) 2016 David Bollinger (davebollinger at gmail dot com)

for pure Lua 5.1 (tested against 5.1.5) 3/25/2016

Lua-specific differences in this translation:

  • support for multiple instances
  • the "class" is merely a "factory" NOT the generator itself
  • init_by_array is 1-based (per Lua idiom)
  • methods to get\set state
  • math library work-alikes

(granted that much of this is superfluous/redundant with the release of Lua 5.3)

Bonus: successfully passes the validation test :D

--example usage (long-form / multiple-instance form):
mt19937ar = require("mt19937ar")
mt1 = mt19937ar.new()
mt1:createValidationOutput()

mt2 = mt19937ar.new()
mt2:init_genrand(1234)
r = mt:genrand_int32()

mt3 = mt19937ar.new()
mt3:init_genrand(2345)
s = mt3:getState() -- save prior to gen
r = mt3:genrand_real2() -- advance state
mt3:setState(s) -- restore prior state
r = mt3:genrand_real2() -- regen from same prior state

--validation usage (short-form / single-instance form)
require("mt19937ar").new():createValidationOutput()

mt19937ar-lua's People

Contributors

davebollinger avatar

Watchers

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