W3cubDocs

/Pony

MT

[Source]

A Mersenne Twister. This is a non-cryptographic random number generator. This should only be used for legacy applications that require a Mersenne Twister, otherwise use Rand.

class ref MT is
  Random ref

Implements

Constructors

create

[Source]

Create with the specified seed. Returned values are deterministic for a given seed.

new ref create(
  x: U64 val = 5489,
  y: U64 val = 0)
: MT ref^

Parameters

  • x: U64 val = 5489
  • y: U64 val = 0

Returns

Public Functions

next

[Source]

A random integer in [0, 2^64)

fun ref next()
: U64 val

Returns

has_next

[Source]

fun tag has_next()
: Bool val

Returns

u8

[Source]

fun ref u8()
: U8 val

Returns

u16

[Source]

fun ref u16()
: U16 val

Returns

u32

[Source]

fun ref u32()
: U32 val

Returns

u64

[Source]

fun ref u64()
: U64 val

Returns

u128

[Source]

fun ref u128()
: U128 val

Returns

ulong

[Source]

fun ref ulong()
: ULong val

Returns

usize

[Source]

fun ref usize()
: USize val

Returns

i8

[Source]

fun ref i8()
: I8 val

Returns

i16

[Source]

fun ref i16()
: I16 val

Returns

i32

[Source]

fun ref i32()
: I32 val

Returns

i64

[Source]

fun ref i64()
: I64 val

Returns

i128

[Source]

fun ref i128()
: I128 val

Returns

ilong

[Source]

fun ref ilong()
: ILong val

Returns

isize

[Source]

fun ref isize()
: ISize val

Returns

int_fp_mult[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]

[Source]

fun ref int_fp_mult[optional N: ((U8 val | U16 val | U32 val | 
    U64 val | U128 val | ULong val | 
    USize val) & Real[N] val)](
  n: N)
: N

Parameters

  • n: N

Returns

  • N

int[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]

[Source]

fun ref int[optional N: ((U8 val | U16 val | U32 val | 
    U64 val | U128 val | ULong val | 
    USize val) & Real[N] val)](
  n: N)
: N

Parameters

  • n: N

Returns

  • N

int_unbiased[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]

[Source]

fun ref int_unbiased[optional N: ((U8 val | U16 val | U32 val | 
    U64 val | U128 val | ULong val | 
    USize val) & Real[N] val)](
  n: N)
: N

Parameters

  • n: N

Returns

  • N

real

[Source]

fun ref real()
: F64 val

Returns

shuffle[A: A]

[Source]

fun ref shuffle[A: A](
  array: Array[A] ref)
: None val

Parameters

Returns

Private Functions

_populate

[Source]

Repopulates the state array.

fun ref _populate()
: None val

Returns

_n

[Source]

fun tag _n()
: USize val

Returns

_m

[Source]

fun tag _m()
: USize val

Returns

_n1

[Source]

fun tag _n1()
: USize val

Returns

_mask

[Source]

fun tag _mask(
  x: U64 val,
  y: U64 val)
: U64 val

Parameters

Returns

_matrix

[Source]

fun tag _matrix(
  x: U64 val)
: U64 val

Parameters

Returns

_mix

[Source]

fun tag _mix(
  x: U64 val,
  y: U64 val)
: U64 val

Parameters

Returns

_lower

[Source]

fun ref _lower(
  i: USize val,
  x: U64 val)
: U64 val ?

Parameters

Returns

_upper

[Source]

fun ref _upper(
  i: USize val,
  x: U64 val)
: U64 val ?

Parameters

Returns

_wrap

[Source]

fun ref _wrap()
: U64 val ?

Returns

_u64_unbiased

[Source]

fun ref _u64_unbiased(
  range: U64 val)
: U64 val

Parameters

  • range: U64 val

Returns

© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/random-MT