-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
135 lines (128 loc) · 4.41 KB
/
index.html
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<link
href="https://fonts.googleapis.com/css2?family=Poppins&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="./style.css"
/>
<title>Mersenne Visualizer</title>
</head>
<body>
<header>
<h1>Mersenne Twister Visualizer</h1>
</header>
<nav>
<ul class="nav-list">
<li>
<a
class="nav-links"
href="./index.html"
><u>Home</u></a
>
</li>
<li>
<a
class="nav-links"
href="./Random Colors.html"
>Random Colors</a
>
</li>
<li>
<a
class="nav-links"
href="./blackAndWhite.html"
>Heat Map</a
>
</li>
<li>
<a
class="nav-links"
href="./javascript.html"
>JavaScript Code</a
>
</li>
</ul>
</nav>
<h2>What is Random?</h2>
<p class="home-par1">
What do a dice roll, future weather conditions, and quantum
mechanics all have in common?<br />
As far as we humans can tell, these 3 things are all completely
random, or at least based on<br />
conditions we don't yet understand. Anything can be defined as
random so long as it is<br />
"lacking a definite plan, purpose, or pattern." This becomes a
rather big problems for<br />
computers, since by their deterministic nature they produce
predictable outcomes 100% of the<br />
time; given the same input, a computer will give you the same
output, without deviation, every<br />
time. So how do we get around this problem? Randomness can come in
quite handy for<br />
certain applications, but by their very nature computers cannot be
random. The answer is<br />
pseudorandomness. Although computers can never be truly random, it
turns out they're very<br />
good at faking it.
</p>
<h3>How Can We Fake It?</h3>
<p class="home-par2">
Enter pseudorandom number generators. These are algorithms that
generates numbers which appear to be random to us humans, but are
actually deterministic and predictable. You feed the algorithm a
starting number called a 'seed,' perform a series of math operations
on that number, and voila, out comes a number that looks completely
random. Common operations done on the numbers are exponentiation and
bit-shifts. Because these algorithms are predictable and only
pseudorandom, if you give it the same seed it will produce the same
numbers. Every programming language and internet browser has a PRNG
built in to conveniently provide random numbers to us when needed.
However, not all PRNG algorithms are created equal. There comes a
point in every algorithm that the numbers will start repeating
themselves. The amount of numbers you generate before they start
repeating is what is known as the 'period.' A small period is
usually the sign of a bad algorithm. Another sign of a bad algorithm
is if the numbers are not distributed equally. For example if could
generate large numbers more often than it generates small numbers.
Every algorithm must strike a balance of appearing random, but also
being fast. Being very random but very slow is typically not ideal.
</p>
<h4>The Mersenne Twister</h4>
<p class="home-par3">
A good balance of speed and randomness is where the Mersenne Twister
shines. Developed in<br />
1997 by Makoto Matsumoto and Takuji Nishimura, the MT is one of the
most widely used PRNGs<br />
to date. Excel, Python, and MATLAB are a few examples among many
more that all use the <br />
Mersenne Twister as the built in PRNG. The name comes from it's
period length, which<br />
is 2<sup>19937</sup>-1, a Mersenne prime, and then 'twisting'
(mostly performing bitwise operations) an array<br />
to generate the pseudo-random numbers. When the Mersenne Twister was
published in 1997 it<br />
corrected a lot of the problems that older PRNGs were suffering
from. Today, it still holds<br />
up as being fast and reliably random for most common use-cases,
although some disadvantages<br />
such as not being cryptographically secure have arisen (newer
versions of MT have been<br />
published to correct these flaws). All in all, the Mersenne Twister
is a fantastic PRNG that<br />
should be appreciated.
</p>
<script
type="module"
src="canvas.js"
></script>
</body>
</html>