Article 6ZY4V A mental random number generator

A mental random number generator

by
John
from John D. Cook on (#6ZY4V)

think_random2.jpg

George Marsaglia was a big name in random number generation. I've referred to his work multiple times here, most recently in this article from March on randomly generating points on a sphere. He is best remembered for his DIEHARD battery of tests for RNG quality. See, for example, this post.

I recently learned about a mental RNG that Marsaglia developed. It's not great, but it's pretty good for something that's easy to mentally compute. The output is probably better than if you simply tried to make up random numbers; people are notoriously bad at doing that. Hillel Wayne explores Marsaglia's method in detail here.

Here's a summary the generator in Python.

state = 42 # Set the seed to any two digit numberdef random_digit(): tens = lambda n: n // 10 ones = lambda n: n % 10 global state state = tens(state) + 6*ones(state) return ones(state)
Related postsThe post A mental random number generator first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments