Module tinymt32

TinyMT 32-bit pseudo random generator module in pure Erlang.

Copyright © 2012-2016 Kenji Rikitake, Mutsuo Saito, Makoto Matsumoto, Kyoto University, Hiroshima University, The University of Tokyo

Authors: Kenji Rikitake (kenji.rikitake@acm.org), Mutsuo Saito, Makoto Matsumoto.

Description

TinyMT 32-bit pseudo random generator module in pure Erlang

Data Types

intstate32()

abstract datatype: intstate32()

Internal state data type for TinyMT. Internally represented as the record #intstate32{}, including the 127bit seed and 96bit polynomial data.

uint32()

abstract datatype: uint32()

32bit unsigned integer type.

Function Index

init/2Initialize default polynomial for TinyMT and returns the internal state.
init_by_list32/2Generate a TinyMT internal state from a list of 32-bit integers.
next_state/1Advance TinyMT state for one step.
seed/0Set the default seed value to TinyMT state in the process directory (Compatible with random:seed/1).
seed/1Set the seed value to TinyMT state in the process directory.
seed/3Set the seed value to TinyMT state in the process directory with the given three unsigned 32-bit integer arguments (Compatible with random:seed/3).
seed0/0Set the default seed value to TinyMT state in the process directory (Compatible with random:seed0/0).
setgenparams/1Set the generation parameter values to TinyMT polynomials in the process directory, with the given three-element tuple of unsigned 32-bit integers.
setgenparams/3Set the generation parameter values to TinyMT polynomials in the process directory, with the given three unsigned 32-bit integer arguments.
temper/1Generate 32bit unsigned integer from the TinyMT internal state.
temper_float/1Generate 32bit-resolution float from the TinyMT internal state.
uniform/0Generate 32bit-resolution float from the TinyMT internal state in the process dictionary.
uniform/1Generate given range of integers from the given TinyMT internal state in the process dictionary.
uniform_s/1Generate 32bit-resolution float from the given TinyMT internal state.
uniform_s/2Generate given range of integers from the given TinyMT internal state.

Function Details

init/2

init(R::intstate32(), S::uint32()) -> intstate32()

Initialize default polynomial for TinyMT and returns the internal state.

init_by_list32/2

init_by_list32(R::intstate32(), K::[uint32()]) -> intstate32()

Generate a TinyMT internal state from a list of 32-bit integers.

next_state/1

next_state(Intstate32::intstate32()) -> intstate32()

Advance TinyMT state for one step. Note: running temper function is required to obtain the actual random number.

seed/0

seed() -> intstate32()

Set the default seed value to TinyMT state in the process directory (Compatible with random:seed/1).

seed/1

seed(X1::{integer(), integer(), integer()}) -> undefined | intstate32()

Set the seed value to TinyMT state in the process directory. with the given three-element tuple of unsigned 32-bit integers (Compatible with random:seed/1).

seed/3

seed(A1::integer(), A2::integer(), A3::integer()) -> undefined | intstate32()

Set the seed value to TinyMT state in the process directory with the given three unsigned 32-bit integer arguments (Compatible with random:seed/3).

seed0/0

seed0() -> intstate32()

Set the default seed value to TinyMT state in the process directory (Compatible with random:seed0/0).

setgenparams/1

setgenparams(X1::{integer(), integer(), integer()}) -> undefined | intstate32()

Set the generation parameter values to TinyMT polynomials in the process directory, with the given three-element tuple of unsigned 32-bit integers. Note well that the parameter values must be guaranteed by the TinyMT Dynamic Creator. This function will not validate the parameters. If seed is not set in the process dictionary, this function will call seed0/0 first, then set the generation parameter values.

setgenparams/3

setgenparams(MAT1::integer(), MAT2::integer(), TMAT::integer()) -> undefined | intstate32()

Set the generation parameter values to TinyMT polynomials in the process directory, with the given three unsigned 32-bit integer arguments. Note well that the parameter values must be guaranteed by the TinyMT Dynamic Creator. This function will not validate the parameters. If seed is not set in the process dictionary, this function will call seed0/0 first, then set the generation parameter values.

temper/1

temper(Intstate32::intstate32()) -> uint32()

Generate 32bit unsigned integer from the TinyMT internal state.

temper_float/1

temper_float(R::intstate32()) -> float()

Generate 32bit-resolution float from the TinyMT internal state. (Note: 0.0 < result < 1.0)

uniform/0

uniform() -> float()

Generate 32bit-resolution float from the TinyMT internal state in the process dictionary. (Note: 0.0 < result < 1.0) (Compatible with random:uniform/0)

uniform/1

uniform(N::pos_integer()) -> pos_integer()

Generate given range of integers from the given TinyMT internal state in the process dictionary. (Note: 1 =< result =< N (given positive integer)) (Compatible with random:uniform/1, though the algorithm is different; see uniform_s/2 for the details)

uniform_s/1

uniform_s(R0::intstate32()) -> {float(), intstate32()}

Generate 32bit-resolution float from the given TinyMT internal state. (Note: 0.0 < result < 1.0) (Compatible with random:uniform_s/1)

uniform_s/2

uniform_s(Max::pos_integer(), R::intstate32()) -> {pos_integer(), intstate32()}

Generate given range of integers from the given TinyMT internal state. (Note: 1 =< result =< MAX (given positive integer)) (Compatible with random:uniform_s/2, though the algorithm is different; retry if the temper/1 does not give a result which guarantee the equally-probabilistic results between the given range of integers)


Generated by EDoc