-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathMt19937ar.txt
More file actions
89 lines (60 loc) · 2.96 KB
/
Mt19937ar.txt
File metadata and controls
89 lines (60 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
*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