update of lecture notes
This commit is contained in:
@@ -1669,7 +1669,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Random Numbers\n",
|
||||
"## Random Numbers\n",
|
||||
"\n",
|
||||
"Uniform deviates are just random numbers that lie within a specified range\n",
|
||||
"(typically 0 to 1), with any one number in the range just as likely as any other. They\n",
|
||||
@@ -1686,7 +1686,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random Numbers, better name: pseudo random numbers\n",
|
||||
"## Random Numbers, better name: pseudo random numbers\n",
|
||||
"\n",
|
||||
"A disclaimer is however appropriate. It should be fairly obvious that \n",
|
||||
"something as deterministic as a computer cannot generate purely random numbers.\n",
|
||||
@@ -1706,7 +1706,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG\n",
|
||||
"## Random number generator RNG\n",
|
||||
" The most common random number generators are based on so-called\n",
|
||||
"Linear congruential relations of the type"
|
||||
]
|
||||
@@ -1750,7 +1750,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG and periodic outputs\n",
|
||||
"## Random number generator RNG and periodic outputs\n",
|
||||
"\n",
|
||||
"The problem with such generators is that their outputs are periodic;\n",
|
||||
"they \n",
|
||||
@@ -1798,7 +1798,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG and its period\n",
|
||||
"## Random number generator RNG and its period\n",
|
||||
"Typical periods for the random generators provided in the program library \n",
|
||||
"are of the order of $\\sim 10^9$ or larger. Other random number generators which have\n",
|
||||
"become increasingly popular are so-called shift-register generators.\n",
|
||||
@@ -1822,7 +1822,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Random number generator RNG, other examples\n",
|
||||
"## Random number generator RNG, other examples\n",
|
||||
"Such a generator again produces a sequence of pseudorandom numbers\n",
|
||||
"but this time with a period much larger than $M$.\n",
|
||||
"It is also possible to construct more elaborate algorithms by including\n",
|
||||
@@ -1877,7 +1877,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG, other examples\n",
|
||||
"## Random number generator RNG, other examples\n",
|
||||
"Instead of using modular addition, we could use the bitwise\n",
|
||||
"exclusive-OR ($\\oplus$) operation so that"
|
||||
]
|
||||
@@ -1910,7 +1910,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG, RAN0\n",
|
||||
"## Random number generator RNG, RAN0\n",
|
||||
"\n",
|
||||
"We show here how the linear congruential algorithm can be implemented, namely"
|
||||
]
|
||||
@@ -1987,7 +1987,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG, RAN0\n",
|
||||
"## Random number generator RNG, RAN0\n",
|
||||
"\n",
|
||||
"To see how this works we note first that"
|
||||
]
|
||||
@@ -2019,7 +2019,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG, RAN0\n",
|
||||
"## Random number generator RNG, RAN0\n",
|
||||
"We can now rewrite Eq. ([14](#eq:rntrick1)) as"
|
||||
]
|
||||
},
|
||||
@@ -2087,7 +2087,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Random number generator RNG, RAN0\n",
|
||||
"## Random number generator RNG, RAN0\n",
|
||||
"The term $[N_{i-1}/q]r$ is always smaller or equal $N_{i-1}(r/q)$ and with $r < q$ we obtain always a \n",
|
||||
"number smaller than $N_{i-1}$, which is smaller than $M$. \n",
|
||||
"And since the number $N_{i-1}\\mathrm{MOD} (q)$ is between zero and $q-1$ then\n",
|
||||
@@ -2105,7 +2105,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Random number generator RNG, RAN0 code"
|
||||
"## Random number generator RNG, RAN0 code"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2457,7 +2457,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Which RNG should I use?\n",
|
||||
"## Which RNG should I use?\n",
|
||||
"* C++ has a class called **random**. The [random class](http://www.cplusplus.com/reference/random/) contains a large selection of RNGs and is highly recommended. Some of these RNGs have very large periods making it thereby very safe to use these RNGs in case one is performing large calculations. In particular, the [Mersenne twister random number engine](http://www.cplusplus.com/reference/random/mersenne_twister_engine/) has a period of $2^{19937}$. \n",
|
||||
"\n",
|
||||
"* Add RNGs in Python\n",
|
||||
|
||||
Reference in New Issue
Block a user