Yes We Have Random Bananas

If you ask a normal person to pick a random number, they’ll usually just blurt out a number. But if you ask a math-savvy person for a random number, you’ll probably get a lecture about how hard it is to pick a truly random number. But if you ask [Valerio Nappi], you might just get a banana.

His post, which is in two parts, details how what computers generate are actually pseudo-random numbers. You can easily make sure that every number has the same probability of selection as any other number. The problem is that you have to start with something — usually called a seed. For the purposes of playing games, for example, you can grab some source of entropy like how many microseconds since a hardware timer last rolled over, the number of input pulses you’ve received from a mouse lately, or how long you had to wait for the enter key to depress after asking the user to press it. But if you know that seed and the algorithm you can perfectly predict what number the computer will generate next so it isn’t truly random.

The best random number generators use things like thermal resistor noise or the decay of radioactive materials. Ah, you might see where this is going, then. Bananas have potassium and a small percentage of potassium is radioactive. Turns out the hardware for this project has been on Hackaday.io but the blog posts were only recently translated to English. If you visit that page, you can see how a banana can even compute pi! With a little help, of course.

It is amazing how much stuff around you is radioactive if you look for it. Just be careful the shadowy agents hanging around your neighborhood don’t find your banana bomb.

36 thoughts on “Yes We Have Random Bananas”

1. “you can see how a banana can even compute pi!”
Does that make banana pie ?

1. Redhatter (VK4MSL) says:

Maybe the detector needs to be plugged into a Banana Pi first…

1. The Commenter Formerly Known As Ren says:

So, the Pi are squared?

2. ChrisMicro says:

There is a natural radioactivity. How much does the banana increase this? Is it irrelevant and the whole thing a version of “click bait”?

1. Olivier says:

There’s actually something to this, depending on where you live the background radiation will be less than or equal to 1 banana, you can find maps online telling you the amount of radiation you get in your area and apparently a banana “produces approximately 98.2 nanosieverts”

Having that radiation come from a small area makes measuring/using it easier, more banana’s would be better, but even the 1 should at least have some effect compared to just background radiation.

1. Paul says:

The statement a banana “produces approximately 98.2 nanosieverts” is nonsense when out of context like this.

The actual (unverified) claim is something like “When ingested, a banana will give a human a calculated effective dose of approximately 98.2 nanosieverts.” (with the suspiciously-precise number of significant figures left intact.)

Dose from natural background radiation is highly variable, but roughly 2 mSv/yr. So you *might* say, dose from background radiation is equal to what you get from eating (…doing the arithmetic…) 55 bananas per day.

The real joke though is that we don’t get much radiation dose at all from the gammas we detect from decaying potassium-40. These detectable gammas account for only 10% of the decays, and the resulting radiation generally just escapes the human body. The biological dose we DO get is from the other 90% of the decays, which produce a highly-energetic beta particle that promptly gets stopped by the nearest cell, wreaking local havoc there.

1. Olivier says:

Guess i went a bit too quick and assumed that the 98.2 number a Google search got me was “nanosieverts per hour”, because the number i found on a map (Europe’s “Joint Research Centre Radioactivity Environmental Monitoring” site) was per hour too. But based on your explanation i guess ‘the banana number’ wasn’t that at all :P

My mistake, thanks for the correction!! :)

2. Ben says:

With a very nice germanium detector you can see and identify the potassium line in a banana. The line goes away if you move the detector away from the banana. However you are correct; the count rate is tiny and I am almost certain is no way that this detector can detect it above background.

3. Andrew says:

Needs a banana for scale.

1. Viktor says:

Change in gravity, sure.

4. Artenz says:

If you want a random seed, just grab a digital camera, take a picture of your desk or your face, and calculate a hash. Program that hash in a microcontroller in such a way that nobody can access it.

1. Anton says:

That’s a hard-coded seed, which defeats the whole point of having a random seed in the first place. For instance, let’s say you’re producing a slot machine and you use this method. Someone could:
– Obtain one unit and dig into it to find the initial seed
– Record the results from one unit for a while, then find a slightly younger unit and perfectly predict its outcomes
– If the PRNG is imperfect, they could collect enough data to get to the seed. This one is less likely though since it amounts to brute-forcing encryption

And there are probably a host of other issues.

PRNGs aren’t enough for secure applications. They don’t generate randomness; they only allow you to get more mileage out of existing randomness.

1. Truth says:

+1,000,000

2. Artenz says:

Each unit would have a unique seed, of course, and it would have a cryptographically secure random generator, if such security is required for the applications.

2. Joseph Eoff says:

That’s a truly random number – once.

‘Nuff said.

1. Artenz says:

No, it’s a seed for a random number generator. If you use a 256 bit seed, you can easily generate high quality random numbers until the end of the universe, and you can easily use a much larger seed.

1. irox says:

“No”
Sounds like a random generated seed for a pseudo random number generator. As Joseph Eoff said, that’s a truly random number, once [1]. What you consider “high quality (pseudo) random numbers” is likely only good for some application.

[1] Even this may have flaws, for example biases in the hashing algorithm may skew the set of possible random numbers you get.

1. Artenz says:

A pseudo random generator with a real random seed is good enough for *any* application, provided that the algorithm is up to the desired standard.

2. irox says:

@Artenz

Which standard? Are you meaning NIST SP 800-90A?

Or by “*any* application”, maybe you mean any application with a government back door?

3. Artenz says:

I mean any standard that you want. For any requirement that you have with respect to randomness or security of your random generator, it is possible to create a pseudo random sequence to meet these requirements.

4. irox says:

You seem to be claiming that for any application, pseudo random number streams will be just as good as truly random number streams. The problem is there is a limit to how random a pseudo random number stream is (one of the reasons that true random number research exists), this limits their effectiveness in some applications.

Maybe checkout the answers to this question for an overview of the pseudo random number generation flaws (this covers an example with a 256bit seed like you are suggesting):
https://superuser.com/questions/712551/how-are-pseudorandom-and-truly-random-numbers-different-and-why-does-it-matter

2. Valerio says:

This very same xkcd is on the back of the PCB :)

5. ian 42 says:

the esp32 – using random wifi signals – is pretty good..

1. Varga Tom says:

Unless you saturate it..

6. Truth says:

I can’t find the arduino source code for the banana geiger counter that has the randomCore function in it. But returning 16 bits of a timer every time a decay is detected would not be a valid way to retrieve highest quality randomness.

The other thing is that using an ISR (Interrupt Service Routine), is a great way to allow you to do other stuff with your microcontroller, but at a cost of a fixed delay between an event occurring (the Geiger counter generating a pulse with a rising edge indicating that a decay was detected) and your code running and second fixed delay after every event where your tube is ignored. An ISR wastes a nearly constant time (dumping the registers on the stack) before the pulse can be processed and adds extra delay after processing (retrieving registers from the stack), both will cause pulses to be missed! Sometimes the simplest/dumb/stupid solution of sitting there constantly polling the pin for a change can yield many more detection events. Yes it is less elegant, yes it does not allow the MCU to sleep between decays, but I did test ISR vs polling and my detected events were nearly double.

Returning 16 bits from a single decay event is not really returning truly random numbers. (check out https://www.fourmilab.ch/hotbits/how3.html for how it was done, they have generated ~58GiB of the highest quality true randomness over the last 20 years). The modern way would AMLS (Advanced Multi-Level Strategy), but even it does not return 16bits per decay event.

1. valerionew says:

Hey! You’re definitely right. You may want to read the log followup that explains the problems I’ve had with the ISRs. ISRs gave me a lot of troubles. https://hackaday.io/project/157930-banana-random-number-generator/log/146438-observations-on-interrupt-collision-between-arduinos-millis-and-attachinterrupt

Regarding your concerns about the quality of the randomness you may be right. I did not try to assess the quality further because of the limited speed of the generator. Gathering big samples would require just too much time. Thank you for the link to fourmilab, I’ll check it out. Keep in mind, however, that this project was never intended for a professional “production” use, but rather a divulgative and fun project.

2. Artenz says:

The Geiger tube has a sizeable dead time after each pulse, so with a reasonably fast microcontroller, the ISR should be finished well before the next pulse.

7. Unfocused says:

I don’t think that’s how you’re meant to use banana plugs

8. sjm4306 says:

*Banana for both scale and randomness

9. aleksclark says:

I actually thought it was going to use another decay product: the image of the spots developing on the banana. Which, I suspect, would actually work nearly as well.

10. Matt Cramer says:

I was going to suggest a wild-type banana, but they only come with a small number of seeds embedded.

1. mt22 says:

Maybe then you can go back writing the works of Shakespeare?

1. Paul says:

Well, that’s random.

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.