Generate Random Numbers The Hard Way

Your job is to create a random number generator.

Your device starts with a speaker and a membrane. On this membrane will sit a handful of small, marble-size copper balls. An audio source feeds the speaker and causes the balls to bounce to and fro. If a ball bounces high enough, it will gain the opportunity to travel down one of seven copper tubes. Optical sensors in each of the tubes detect the ball and feed data to an Ardunio Mega. When the ball reaches the end of the tube, a robotic hand will take the ball and put it back on the speaker membrane. The magic happens when we write an algorithm such that the audio output for the speaker is a function of how many balls fall down the pipes.

The above is a rough description of [::vtol::]’s art piece: kinetic random number generator. We’re pretty sure that there are easier ways to get some non-determinstic bits, but there may be none more fun to watch.

[::vtol::] is a frequent flyer here on Hackaday Airlines. Where else would you showcase your 8-bit Game Boy Photo Gun or your brainwave-activated ferrofluid monster bath? Would it shock you to find out that we’ve even covered another kinetic random number generator of his?  Fun stuff!

24 thoughts on “Generate Random Numbers The Hard Way

  1. Nice piece of art, certainly adds a nice sensitivity feedback to the process.
    But ever after I read about the PHP rand() bug … I require a random RBG plot as minimal proof something is worthy of being called random. https://softwareengineering.stackexchange.com/questions/76229/predicting-the-output-of-phps-rand

    Sure, it can be “random enough” for some uses, but random doesn’t happen randomly. Or it does. Or not. Or maybe.

    1. While we’re here, have a good LOL at all the people on stackexchange saying you should use mt_rand() (Mersenne Twister) for anything security-related. That uses a reversible generation function which means that if you can observe a few hundred bytes of mt_rand() output, you can obtain the entire internal state of the generator, and therefore predict all future output. Oops.

      If you’re doing anything security related, you need a crypto-secure RNG, for which the additional critical property is that past and future outputs are not guessable even if you observe a lot of outputs. MT has a good output distribution and no problematic short periodicities (patterns visible in the output, like PHP-rand()), but it does not have unpredictability.

      1. a) good advice about crypto-PRNGs for crypto purposes
        b) most crypto-PRNGs just toss a one-way hash or encryption scheme on the output of something more trivial — a simple counter is sufficient (NIST SP-800-90A).

        Crypto PRNGs aren’t actually harder, they’re easier, given good hashing functions as primitives. HASH_DBG: Count up, hash the counter with the previous hashed value. Repeat.

        MT is good for Monte Carlo simulations, though.

  2. Put an optical mouse at a slight angle, slightly elevated from it’s usual position. The lack of focusing will cause the cursor to judder. Now just take the x and y coordinates add them, divide them, root them if you wish, use the least significant figures from the result. Cheap and fairly random.

    1. no no no no no, a lottery ball machine let’s you actually see the number in a very convenient way. Therfore this has to be something else, I guess it is some sort of art?
      Considering the setup of copper tubing, servos, lights,lot’s of plexiglass it’s literally a piece of art. Considering the uselessness of it, it has to be art. And judging from the vimeo video where there is crowd forming around the contraption in a very clean (looking) room I can only conclude that this is indeed art.

      I not an art fan, as I usually don’t understand it. So I need some explanation, from the exhibitor or creator, in order to understand the ideas behind it. I noticed the second video that has the creator saying something, but not much. So in short, it makes me think what could he meant with it. So, if art is created to make the observer think about the piece and it’s message. I can only say that he reached his goal.

      Can’t wait so see his next contraption on hackaday.

    1. “This results in a constant change in the sound and the spectator’s observation of the system’s attempts to retain balance and continue its work.”

      That is the purpose of the machine. It’s not about generating random numbers.

  3. I want to fill an aquarium with glitter and water and film them. I’d use the output of the camera to create a number that would control some agitators to mix the glitter randomly so it dosn’t settle.
    Then I’d put a sticker on my computer saying it’s protected by sparkle power.

Leave a Reply to MarcCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.