Module mwc

This module implements a multiply-with-carry RNG.

Based on code and algorithm by George Marsaglia: MWC

To use the plugin, add the following in build.settings:

plugins = {  
    ["plugin.mwc"] = { publisherId = "com.xibalbastudios" }
}

Sample code is available here.

Functions

MakeGenerator ([opts]) Instantiates a new random generator.
MakeGenerator_Lib ([opts]) Variant of MakeGenerator, where the generators behave like math.random.


Functions

MakeGenerator ([opts])
Instantiates a new random generator.

Parameters:

  • opts table

    Generator options. Fields:

    • z Z seed; if absent, uses a default.
    • w W Seed; if absent, uses a default.

Returns:

    function May be called as z, w = gen("get_zw"), in which case z and w will be the current Z and W seeds, respectively.

    Otherwise, called as result = gen(how). When how is "float", result will be a random number ∈ [0, 1); with anything else, it will instead be a random non-negative 32-bit integer.

MakeGenerator_Lib ([opts])
Variant of MakeGenerator, where the generators behave like math.random.

Parameters:

Returns:

    function Generator with the semantics of math.random.

    This may also be called as z, w = gen("get_zw"), in which case z and w will be the current Z and W seeds, respectively.

generated by LDoc 1.4.0