Summer of Math Exposition

Presented by 3Blue1Brown 3blue1brown

Exploring PRNGs & Random Tests

Audience:

A Desmos notebook explaining PRNG basics, Lehmer RNGs, and randomness testing targeted towards middle/high school students



thumbnail

Analytics

6.62 Overall score*
14 Rank
8 Votes
7 Comments

Comments

7.5

Motivation: 7/9. The usefulness of good random number generation in video games is common knowledge. But if you want to highlight a broader range of applications, maybe mention Monte Carlo simulations or algorithms that rely on probability?

Clarity: 6/9. You imply the frequency histogram is a 2D counterpart to the 3D consecutive values graph when it is not—maybe include a 2D consecutive values graph for comparison?

Personally, I would have also explained the mod function before the part where the reader can experiment with the Lehmer RNG parameters, since it would explain patterns such as even moduli tending to result in shorter periods. Moreover, as long as you are presenting a frequency histogram example, it might help to include several and compare a good PRNG with a bad one.

Novelty: 8/9. While I have seen PRNGs as an application of modular arithmetic before, I had not even considered that consecutive outputs might not be approximately independent for otherwise “good” PRNGs. It would be interesting to see someone elaborate on how this effect could be avoided.

Memorability: 8/9. It is interesting to see how modular arithmetic can be used to construct simple PRNGs, the use of sliders made the article more engaging, and the 3D graphs highlight the consecutive outputs issue well.

8

Motivation - It is clear from the beginning why this topic matters and the author created a compelling story through the history of PRNGs, examples, interactive features, and descriptions of why this is interesting and important.

Clarity - A good fit for high school students, most terms are explained or motivated nicely, a bit more discussion might be nice but overall the writing and presentation of ideas is very clear for people with little background on the subject.

Novelty - The author has done a good job of presenting a technical topic with storytelling that creates an enjoyable read. I like the level of detail combined with the story of how the PRNGs were created and how they are used. I learned from the end of the reading that PRNGs can be used for generating video game terrain!

Memorability - The visuals and interactive features were clearly presented and will help me remember what I learned from reading this post.

7

Oh, I was looking forward to seeing some Desmos Notebooks in this year’s SoME! It was very well written and illustrated. I only wished you leveraged Desmos better and made interactive widgets.

4.5

Who are you? Where’s your name on the “blog” post? Are you representing Desmos??? (which is not, but it really looks like it. --- i partly blame Desmos for abducting author’s name, unlike GeoGebra’s Activity)

You tag the target audience for middle to high school students. You need to motivate (much) more. Your introduction section already fails the job. Don’t start with technical details that you would use to communicate with people working in the field for thousands of hours. Start with why should the audience care about it. Best explained in an ELI5 manner. Think of the audience as having no clue the subject at all, only knowing basic mathematical operaions: add, sub, mul, div, and sequence of numbers (array).

Spend a few paragraph explain why we use PRNGs at all? Why can’t computer random? No need to be a deep-dive into technical detail. But at least establish the mental framework for why this is essential.

Middle-square --- I think this section would benef to the audience the most if it also had an “interactive” applet too, not only in the later section. Basically, if you can guide the audience by experimenting, save your words and let them experiment themselves.

Also, what exactly is the “middle” in the middle-squared method? Your “worded” example uses 2-digit numbers, but your figure uses numbers with more digits. This is quite a discrepancy… Also, when the number of digit is changes, how do we handle that? --- a standard com-sci textbook would pad them with zeros to keep “the number of digit” stayed the same, eliminate the ambiguity.

Next, the Lehmer RNG. The order of the slider bars for the interactive applet should be: seed, m, and a. It should not allow negative seed (we’re working with non-negative integer group anyway). Meanwhile, m should allow values larger than 0-20. Lastly, if possible withing Desmos, a should be dynamically limited by the current value of m, since it is fruiteless to consider a > m (we can split a = a_0 + m, and then the +m part will vanished within the modulo arithemtic.)

5

Nice introduction to random number generation.

5.7

I suppose because it was at a high school level, you couldn’t go into too much detail on the theory of why the generator wasn’t so random. It would have been good opportunity to introduce various correlations and maybe give an example where that correlation can be seen and easy to explain. On the other hand I didn’t realize how sophisticated an interface you could build with Desmos.

7

This was a very engaging read on so many levels: each example was motivated by a story and was rewarding to understand; the order in which the examples were presented gave the reader an evolving sense of the ways that the question of finding a good PRNG can be complicated; the Desmos embeddings were intuitive to play with and cleanly organized, and the prose itself was inviting. I loved the twist at the end, where the RANDU PRNG is revealed to fail the spectral test, especially because it was implicitly foreshadowed by the discussion preceding it, of the modulus operation having the issue of repeating outputs periodically and of having a particular range; the reader, noticing the modulus operation in the RANDU algorithm, may ask whether these issues might also occur here. I also really like the use of open ended “extra challenges” to show readers how PRNGs can be used for art and game development!

I did feel like the article ended a little abruptly, and I think part of that feeling came from wanting a quick explanation of why RANDU’s points lie on planes when three consecutive outputs are plotted in R3\mathbb{R}^3. I don’t think it would be too difficult to demonstrate that three consecutive outputs must satisfy the equation (xk+2)mod231=(6xk+19xk)mod231,(x_{k+2})\mod{2^{31}}=(6x_{k+1}-9x_k)\mod{2^{31}}, as in the following wikipedia page: https://en.wikipedia.org/wiki/RANDU#Problems_with_multiplier_and_modulus. This could have lead to a discussion of how, just like how all ordered pairs (x,y)(x,y) which satisfy y=mx+by=mx+b lies on a line in R2\mathbb{R}^2, all ordered pairs (x,y,z)(x,y,z) which satisfy ax+by+cz=0ax+by+cz=0 lies on a plane in R3\mathbb{R}^3, which can be easily seen by noticing that if you keep one of the variables, say zz, constant, then you get an equation of the form y=mx+by=mx+b. This would connect these ideas to topics that a middle/high school student has already learned or will learn in the future, which would give a nice “aha!” moment to end with.

But overall, I really liked this article and I think this is a very clever use of the desmos notebook! I can see a teacher being able to easily make use of this article, especially as a project assignment or homework.