From daf55a684cff8bf3b776471b8e12aa158174e96a Mon Sep 17 00:00:00 2001 From: James Schloss Date: Wed, 6 Sep 2023 12:35:15 +0200 Subject: [PATCH] adding skeleton for upcoming chapters --- SUMMARY.md | 3 ++ contents/LCG/LCG.md | 0 contents/RNG/RNG.md | 61 +++++++++++++++++++++++++++++++++++++ contents/diehard/diehard.md | 14 +++++++++ literature.bib | 40 ++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 contents/LCG/LCG.md create mode 100644 contents/RNG/RNG.md create mode 100644 contents/diehard/diehard.md diff --git a/SUMMARY.md b/SUMMARY.md index 412b7fd12..a824db312 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -23,6 +23,9 @@ * [Box Muller Transform](contents/box_muller/box_muller.md) * [How costly is rejection sampling?](contents/box_muller/box_muller_rejection.md) * [Probability Distributions](contents/probability_distributions/distributions.md) +* [Random Number Generation](contents/RNG/RNG.md) + * [Diehard Tests](contents/diehard/diehard.md.md) + * [Linear Congruential Generators](contents/LCG/LCG.md) * [Tree Traversal](contents/tree_traversal/tree_traversal.md) * [Euclidean Algorithm](contents/euclidean_algorithm/euclidean_algorithm.md) * [Monte Carlo](contents/monte_carlo_integration/monte_carlo_integration.md) diff --git a/contents/LCG/LCG.md b/contents/LCG/LCG.md new file mode 100644 index 000000000..e69de29bb diff --git a/contents/RNG/RNG.md b/contents/RNG/RNG.md new file mode 100644 index 000000000..3671d9a61 --- /dev/null +++ b/contents/RNG/RNG.md @@ -0,0 +1,61 @@ +# Random Number Generation + +Quick, try to think of a number between 1 and 10. + +Ok, do you have your number? + +Was it 7? + +Probably not, right? I mean, there is no magic here. +I put down 7 (seemingly at random), and you chose your number seemingly at random. +In general, there should be about a 10% chance that we chose the same number; however, that is statistically not the case. + +For some reason, we naturally choose 7 more than any other integer. The exact probability of choosing 7 is currently up for debate, ranging from roughly 25% {{ "RNG_reddit" | cite }} to 45% {{ "RNG_Numberphile" | cite }}, and there are some interesting papers on related topics you might want to chek out as well {{ "Shepard197582" | cite }} {{ "navarro2008latent" | cite }}. + +My point is that we, as humans are really bad at coming up with random numbers. +Computers, on the other hand, are some of the most sofisticated pieces of technology we have ever built. +They have sometimes trillions of transistors, all working to provide answers to fundamental questions in science and technology. +Surely they are good at creating random numbers, right? + +Yeah, not really. Like, they are fine, but they are machines built by people whowant precise answers. +Randomness is not usually something people want when trying to add $$2+2$$. + +So then what do we do? +Well, white noise (static) is truly random [CITE] and comes about all the time in nature, so we could just put a microphone somewhere and collect random numbers from the world around us. +The problem is that nature is kinda slow at doing this and we want really fast simulations, so it's not in our best interest to just chill by a pond fishing for numbers. +So instead let's come up with complex algorithms that *simulate* randomness as best as we can. +From here on, rather than talking about generating truly random numbers, we will discuss creating "random enough" *pseudo* random numbers. + +In the literature, you might see Random Number Generation being shortened to RNG and Pseudo Random Number generation shortened to PRNG. +The two are often used interchangeable, but there is a small destinction to be made. +Namely that RNG is related to the entire process of generating random numbers, while PRNG is a subset of methods that use the computer to do so. +In certain fields, other terms are used, but these will be covered on a case-by-case basis. + +In these chapters, we'll do our best to cover a bunch of different algorithms and their specific use-cases. +Before doing that, we'll just talk about 2 things: +1. Why we want randomness to begin with +2. How to test for randomness + +## Why do we want random numbers? + +Monte Carlo, simulating nature, etc + +computer graphics / IFS + +Cryptographic hashing + +Note that we need different quality of RNG for this + + +## Testing for Randomness + +Histogram test + +### Bibliography + +{% references %} {% endreferences %} + + + diff --git a/contents/diehard/diehard.md b/contents/diehard/diehard.md new file mode 100644 index 000000000..374a407e7 --- /dev/null +++ b/contents/diehard/diehard.md @@ -0,0 +1,14 @@ +# Diehard Tests + +## Birthday spacings +## Overlapping permutations +## Ranks of matrices +## Monkey tests +## Count the 1s +## Parking lot test +## Minimum distance test +## Random spheres test +## The squeeze test +## Overlapping sums test +## Runs test +## The craps test diff --git a/literature.bib b/literature.bib index 80e55f787..359b63358 100644 --- a/literature.bib +++ b/literature.bib @@ -541,3 +541,43 @@ @misc{box_muller_wiki url={https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform}, year={2022} } + +#------------------------------------------------------------------------------# +# RNG +#------------------------------------------------------------------------------# + +@misc{RNG_reddit, + title={Asking over 8500 students to pick a random number from 1 to 10 [OC]}, + url={https://www.reddit.com/r/dataisbeautiful/comments/acow6y/asking_over_8500_students_to_pick_a_random_number/}, + year={2023} +} + +@misc{RNG_Numberphile, + title={Random Numbers - Numberphile}, + url={https://www.youtube.com/watch?v=SxP30euw3-0}, + year={2013} +} + +@article{Shepard197582, +title = {The internal representation of numbers}, +journal = {Cognitive Psychology}, +volume = {7}, +number = {1}, +pages = {82-138}, +year = {1975}, +issn = {0010-0285}, +doi = {https://doi.org/10.1016/0010-0285(75)90006-7}, +url = {https://www.sciencedirect.com/science/article/pii/0010028575900067}, +author = {Roger N Shepard and Dan W Kilpatric and James P Cunningham}, +} + +@article{navarro2008latent, + title={Latent features in similarity judgments: A nonparametric Bayesian approach}, + author={Navarro, Daniel J and Griffiths, Thomas L}, + journal={Neural computation}, + volume={20}, + number={11}, + pages={2597--2628}, + year={2008}, + publisher={MIT Press} +}