Vim documentation: vital/Random/Mt19937ar
main help file
vital/Random/Mt19937ar.txt random number generator using mt19937ar
Maintainer: Linda_pp <lin90162@gmail.com>
==============================================================================
CONTENTS Vital.Random.Mt19937ar-contents
INTRODUCTION Vital.Random.Mt19937ar-introduction
INTERFACE Vital.Random.Mt19937ar-interface
FUNCTIONS Vital.Random.Mt19937ar-functions
==============================================================================
INTRODUCTION Vital.Random.Mt19937ar-introduction
Vital.Random.Mt19937ar provides a Random Number Generator (RNG) using Mersenne
Twister algorithm. Random numbers generated by mt19937ar have very long period
and high order of equidistribution.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
The algorithm was ported to Vim script by Yukihiro Nakadaira and this module is
imported from the implementation.
https://github.com/ynkdir/vim-funlib/blob/master/autoload/random/mt19937ar.vim
This implementation always generates 32bit number [-2147483648, 2147483647],
even when you use Vim with +num64.
let s:V = vital#{plugin-name}#new()
let s:M = s:V.import("Random.Mt19937ar")
call s:M.srand(1)
echo s:M.rand()
" 1067595299
echo s:M.rand()
" 955945823
call s:M.srand(1)
echo s:M.rand()
" 1067595299
==============================================================================
INTERFACE Vital.Random.Mt19937ar-interface
------------------------------------------------------------------------------
FUNCTIONS Vital.Random.Mt19937ar-functions
srand([{seed}]) Vital.Random.Mt19937ar.srand()
Set a seed of generator. When {seed} is omitted, a return value of
reltime() is used. When {seed} is omitted and vim doesn't have
reltime(), a return value of localtime() is used. The seed is a
number.
rand() Vital.Random.Mt19937ar.rand()
Generate a random number.
Note: A return value is possibly negative. This is because Vim script
doesn't have an unsigned integer type.
new_generator() Vital.Random.Mt19937ar.new_generator()
Create a new Generator object(Vital.Random.Mt19937ar-Generator).
==============================================================================
OBJECTS Vital.Random.Mt19937ar-objects
------------------------------------------------------------------------------
Generator Object Vital.Random.Mt19937ar-Generator
Generator.next() Vital.Random.Mt19937ar-Generator.next()
Get the next random number in the sequence.
Generator.min() Vital.Random.Mt19937ar-Generator.min()
Get the smallest possible value in the output range.
Generator.max() Vital.Random.Mt19937ar-Generator.max()
Get the largest possible value in the output range.
Generator.seed({seeds}) Vital.Random.Mt19937ar-Generator.seed()
Set seeds by array of numbers which initializes the generator. The
size of the array is arbitrary.
==============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl
top - main help file - tag index