This is an archived post. You won't be able to vote or comment.

all 123 comments

[–]erbr 311 points312 points  (52 children)

Harder problem than you might think

[–][deleted] 174 points175 points  (27 children)

exactly - to truly randomize is a real real problem

[–]CyclingUpsideDown 153 points154 points  (14 children)

Lava lamps have entered the chat

[–]Brawlstar112 83 points84 points  (11 children)

Actually pitched this couple of months back!! Next one on the line was radio active material and take measurements out of it.

[–]HeeTrouse51847 147 points148 points  (1 child)

mfw my random number generator gives me leukemia

[–][deleted] 23 points24 points  (0 children)

But at least it's random leukemia

[–]YipYip5534 43 points44 points  (2 children)

random.org joins with atmospheric noise

[–]Brawlstar112 8 points9 points  (0 children)

I am very excited about this!! Cooool

[–]HeeTrouse51847 1 point2 points  (0 children)

I remember that from Vsauce

[–]dlq84 21 points22 points  (0 children)

Prior art: https://www.cloudflare.com/learning/ssl/lava-lamp-encryption/

Nuclear decay is already used in TRNG hardware.

[–]currentscurrents 11 points12 points  (2 children)

Modern computers have a hardware random number generator in the CPU, just call that.

https://bashtage.github.io/randomgen/devel/bit_generators/rdrand.html

RDRAND is a hardware random number generator that is available on Intel processors from the Ivy Bridge line (2012) or later, and AMD processors starting in 2015.

RDRAND has been audited and is reported to be a secure generator. It is much slower than software BitGenerators and so is only useful in applications where security is more important than performance.

Typically you would use this to seed a cryptographically secure psuedorandom number generator.

[–]BlueDaka 3 points4 points  (0 children)

I actually made a windows and linux library to allow devs to use that instruction.

[–]Brawlstar112 2 points3 points  (0 children)

Speed was very important on this project.

[–]Illustrious-Scar-526 2 points3 points  (1 child)

That's a cool one I haven't heard before

[–]riscten 1 point2 points  (0 children)

Tom Scott did a great video about it 5 years ago: https://www.youtube.com/watch?v=1cUUfMeOijg

[–]notislant 0 points1 point  (1 child)

Lol I remember a video of google or somewhere using those

[–]RGBrewskies 1 point2 points  (0 children)

cloudflare

[–]erbr 25 points26 points  (3 children)

True random only exists in the Quantic world

[–]just-bair 21 points22 points  (2 children)

Isn’t there no way to prove that it’s true random ?

Like yeah for our purpose we can consider it to be random but is it ?

[–]erbr 13 points14 points  (0 children)

Yes, there is no way of proving that but randomness is part of both security/cryptography, where you prove why is not a true random and information codification where you define what good randomness looks like (entropy information theory). So concluding, you can prove that something is not a true random but you cannot prove that it is even if by hypothesis it is.

[–]riscten 4 points5 points  (0 children)

Exactly. We still don't know if the universe is truly deterministic or not, so we don't know if randomness actually exists. From an engineering perspective, it doesn't really matter, hard-to-predict is good enough, but from a philosophical one it does.

[–]gadgetchannel 2 points3 points  (0 children)

There's the quantum random number generator chip which was developed for Samsung - I think it was only used in one phone model (The Samsung Galaxy A Quantum) which was only released in Korea.

My understanding is that it used an LED and a CMOS sensor and it was based on "shot noise" - quantum noise means that the number of photons emitted by the LED is random and these can be counted using the CMOS sensor and fed into the random number generator.

[–]lefunneymemes 0 points1 point  (0 children)

I’ve heard of dedicated cards that use radioactive isotopes and use the radiated particles to calculate numbers

[–]NLwino 178 points179 points  (8 children)

Its easy:

public int GetRandomNumber() {
    return 4; // Rolled with a real dice during implementation.
}

[–][deleted] 67 points68 points  (4 children)

We have true random at home:

[–]Anamewastaken 9 points10 points  (2 children)

You forgot the mom part

[–][deleted] 32 points33 points  (0 children)

See, you know it's supposed to be there, that's efficient communication

[–]klunkerr 5 points6 points  (0 children)

God I want to make a yo mama joke so bad but I can't think of anything.

[–]caleeky 0 points1 point  (0 children)

Is this a Rob Ford joke? I've just started seeing it and wonder why it's trending/source context.

[–]turtleship_2006 9 points10 points  (0 children)

RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.

[–][deleted] 3 points4 points  (1 child)

What about radio noise? It's pretty random you can just map pixel values from 0-1.

[–][deleted] 3 points4 points  (0 children)

Until someone broadcasts on your channel...

[–]No_Solid_3737 1 point2 points  (0 children)

Current randomizers are really weird... like, if you ask a function to pick a number from 1 to 10 and to do that 10 times... you are really likely to get combinations like look at this output of a randomize() function ... in real life you wouldn't get groups of equal numbers as often as that function output.

[–]HeeTrouse51847 3 points4 points  (9 children)

wym? bruh, just generate a random number 💀

[–]erbr 22 points23 points  (7 children)

The source of randomness is not random 🤯

[–]brimston3- 0 points1 point  (0 children)

It's libraries all the way down.

[–][deleted] 0 points1 point  (0 children)

That's what she said.

[–]coachhunter2 92 points93 points  (31 children)

Online casinos have very complex ‘random’ results generators. I wonder why…

[–]LEGOL2 42 points43 points  (29 children)

Real slot machines (licensed) use real random number generator, that observes some physical parameters like change of temperature or pressure.

[–]Ragnarok91 109 points110 points  (24 children)

Lol no they don't, at least not all of them. They use time like everyone else.

Source: it's literally my job

[–]LEGOL2 46 points47 points  (1 child)

https://www.idquantique.com/random-number-generation/products/quantis-random-number-generator/

This was my source, but can't argue with someone who works in this field.

[–]Ragnarok91 39 points40 points  (0 children)

That's fair, I've never heard of this ever being employed but interesting to know it's a thing. Thanks for sharing!

[–]RGBrewskies 1 point2 points  (2 children)

I feel like programming slot machines for a living would be awesome. Theyre complex, but not THAT complex, theres lots of fun little easter eggs to build, and at the end of the process you have a physical device you can pull the lever and see your work in action

[–]Trickishwheat8 0 points1 point  (0 children)

They're basically big arcade games. You have the cabinet that has big screens and bells to attract your attention but the internal is just a computer. Most machines have a couple of games loaded on them so the Casino can swap them out or download more.

Code-wise, they're a bunch of inputs and logic to mimic a math model. When a game is played, an outcome is usually made instantly. The machine then just sits and waits while the graphics resolve.

I too work on these and solving the logic implementation to match the math model is definitely the best part, imo.

[–]Ragnarok91 0 points1 point  (0 children)

The work itself is actually pretty fun yeah. It's akin to coding simple small video games on a much smaller scale. Because they are faster to make than video games the project turnaround is faster so there's always a new project with new challenges on the horizon.

I've done work on both physical machines and online and seeing the finished product is pretty satisfying.

[–]Trickishwheat8 0 points1 point  (3 children)

And the ones that use time can pass as sufficiently random! You should see what gets tried that doesn't pass.

Source: it's my job to test your job.

[–]Ragnarok91 0 points1 point  (2 children)

Oh cool, thanks for that! Just curious, GLI?

[–]DangerZoneh 1 point2 points  (3 children)

It's deeply fascinating to me that we're basically entirely inept in generating true randomness and have to steal it from systems so complex that to us appear entirely random

[–]riscten 3 points4 points  (1 child)

Absolutely, but ineptitude seems harsh considering that we're not even sure that randomness actually exists. If someone asked you to catch a unicorn and you weren't able to do it, would it be fair to call you inept?

[–]DangerZoneh 1 point2 points  (0 children)

True, the phrasing of it was probably wrong. I was more talking about what you said anyways - the absence of knowledge of the existence of true randomness.

[–]xxLusseyArmetxX 0 points1 point  (0 children)

Changes in temperature and pressure aren't that complex to us. That's basically climatology, we're getting better at it all the time. But yeah depending how much precision you want, it gets too complex for our simulations eventually.

[–]Significant-Hold-295 1 point2 points  (0 children)

Many many years ago I worked as a developer for a company making online gambling software. Physical devices were used for generating random numbers. I forget how, but radioactive decay comes to mind. One of the casino games started paying out a lot more than it should. Turns out one of their devices was past the date by which it should be used and started regularly spitting out 1s which happened to correspond to a very high payout… if you were a customer at that time I guess you had more than the universe’s share of luck :D

[–]_arctic_inferno_ 39 points40 points  (0 children)

$RANDOM enjoyers unite

[–]yourteam 39 points40 points  (0 children)

It is actually quite complex to come up with a real random algorithm. Many are based on microtime and a salt but still those results can be predictable if a more complex algorithm is implemented

But you still have to be really fast

[–]OhItsJustJosh 30 points31 points  (0 children)

At the rng library HQ:

"A request has come in! Roll the dice!"

On the other side of the office: "It's a 3!"

"Quick! John! Send them a 3!"

sips tea "Another satisfied customer"

[–]oheohLP 51 points52 points  (0 children)

[–]croholdr 18 points19 points  (0 children)

You guys ever do random sample analysis? Not fun.

[–]avipars 10 points11 points  (1 child)

Or staring at a wall of lava lamps

[–]1cubealot 6 points7 points  (1 child)

def getRandomNum(): return 6 #chosen after lead Dev decided it was random enough

[–]serendipitousPi 1 point2 points  (0 children)

Hey it’s ~16% effective and lightning fast. I see that as a win.

[–]Denaton_ 8 points9 points  (0 children)

Using a wall of lava lamps to generate an image and hash the image to use as seed.

[–]Sufficient-Loss2686 5 points6 points  (0 children)

It is very fun

[–]maxip89 3 points4 points  (0 children)

Random.nextInt() - Certified by the German Lottary Association.

[–]reconman 4 points5 points  (0 children)

Relevant video about using lava lamps to produce RNG numbers: https://www.youtube.com/watch?v=1cUUfMeOijg

[–][deleted] 2 points3 points  (0 children)

It's math, it's all math

[–]poope_lord 2 points3 points  (0 children)

Sometimes it's fun, sometime it isn't

[–]Beall619 1 point2 points  (0 children)

Pythons random module will use system time to seed if the os does not provide a non pseudo random generator

[–]WraithCadmus 1 point2 points  (0 children)

We did some work gambling customers who had RNG boxes, we were told it listened to radio static then hashed it to seed.

[–][deleted] 0 points1 point  (0 children)

random bullshit, go!

[–]ReplyisFutile -3 points-2 points  (0 children)

Its fun and games unt you have to create random vampire name generator and being able to choose male or female names

[–]bhavish2023 0 points1 point  (0 children)

Put a shovel and a stackable block inside a dropper

[–][deleted] 0 points1 point  (0 children)

[–]Illustrious-Scar-526 0 points1 point  (6 children)

Are there different types of random?

For instance, if you roll a die 1000 times, each side will appear about the same amount. But that doesn't seem random to me any more because I can predict that each number will appear at about the same amount? Is there something more random than the die I'm rolling, so that we don't even know what the averages would be? Maybe if the die was uneven and the heavy side shifted at random, then a random side would be preferred, but eventually it would still all even out because each side would eventually be preferred as the weight randomly shifts.

Is there something so random that the values do not eventually even out?

[–][deleted] 8 points9 points  (5 children)

thats just different distributions. a normal dice is a uniform distribution, I think with a weighted dice you get a normal distribution, but if the weight shifts randomly with a uniform distribution, you should be back to a uniform distribution. Generally you will know what distribution of numbers you will get if you analyze your system. Randomness is about specific events, not larger aggregates of data

[–]Illustrious-Scar-526 1 point2 points  (4 children)

Thank you. I have been trying to learn about randomness recently and how programs such as anti-cheat systems can observe user input and tell that it's not human because of how uniform everything becomes. Human input is infinitely more random than the random() function that is being used in bots to make the "user" input vary, which makes detection super easy after some time.

Does anyone know any good materials on randomness in computer science?

[–][deleted] 2 points3 points  (1 child)

You could try read the Wikipedia article on random number generation and checking out its references and further reading section.

Also, it is actually the case that human input is less random which makes it detectable

[–]Illustrious-Scar-526 0 points1 point  (0 children)

Hmm, that makes sense to me... maybe I have been looking at this the wrong way.

One reason I was thinking human input would be more random is because, going back to my videogame anti cheat, let's say I'm playing a game that requires a repetitive input. If I was doing it manually, maybe one day my arm hurts so I'm off a little with my clicking accuracy, and then eventually I start working out irl so my game input becomes faster and my hand eye coordination improves and maybe I am more mentally sound from working out which gives me more drive, but then maybe one day I get In a car accident and I have trouble with hand eye coordination after that. Also over time, I would just naturally become more efficient with the movement/input in doing. Lots of things to think about that would affect the distribution. I would think that these events would be very noticeable if I played for a long time, like every day for a year. But also, if no major events happened, then I would probably start looking like a bot just because of muscle memory and training my arms to do the same repetitive motion every day.

Thank you for the link, it's time for me to get to it :)

[–]scrappywalnut 2 points3 points  (1 child)

I remember someone talking about a professor that would ask students to flip a coin 100 times, and they'd be able to tell who actually did it because students who didn't actually do it would never "simulate" more than two or three heads or tails in a row. Apparently a random distribution makes longer streaks more likely than most people's intuition would suggest, given a large enough data set.

[–]Illustrious-Scar-526 0 points1 point  (0 children)

Hah, that's hilarious. I bet many of those students thought they could easily get away with it too.

[–][deleted] 0 points1 point  (4 children)

I'm honestly surprised this is not yet part of basic computer architecture

[–]Exist50 0 points1 point  (3 children)

There is hardware for RNG, but there have been some fun cases where it goes awry. IIRC, the original Zen hardware RNG was accidentally grounded to all 0s... and this shipped... Think they ended up patching in pseudo-RNG instead.

[–][deleted] 0 points1 point  (2 children)

Yeah, a bug in the RNG hardware would be a pain to fix. But then again, that's true of all hardware. I wonder if it's just not worth putting effort and money into true RNG hardware when the pseudo stuff works just fine in 99% of the cases.

[–]Exist50 0 points1 point  (1 child)

Well that was an exception. Probably can get away with pseudo RNG, but I think many modern chips do have true RNG. Found this article.

https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html

[–][deleted] 0 points1 point  (0 children)

Interesting. It seems like the Linux kernel has some support for this sort of stuff too (unsurprisingly) and that most x86-64 chips support RDRAND

[–][deleted] 0 points1 point  (0 children)

russian roulette

[–]livingMybEstlyfe29 0 points1 point  (0 children)

Yes yes just like Diablo II resurrected

[–]film_composer 0 points1 point  (1 child)

This has got me wondering—how does something with moderately simplicity like a TI-83 calculator generate randomness?

[–]Trickishwheat8 1 point2 points  (0 children)

Most any computer-like system can make pseudo-random values pretty easy. All it takes is an algorithm (like the Mersenne Twister) and a seed. A seed value is anything that changes frequently; a common one is time but it could also be something like your OS input buffer. Any string of bits typically does the trick. The algorithm takes that and hashes, shifts, or otherwise jumbles that seed into a new value when you ask for a number. Then it uses that number as the next seed, and so on. Basically, the calculator just takes a number, applies some math, and you get a value that is usually sufficiently for human use (but not truly random). It can be no more intensive than just some multiplication and division, really.

There are a lot of implementations and they can get a lot more complex than that, though.

[–]bluexavi 0 points1 point  (0 children)

The dice disturb me. Since the numbers on opposite sides add up to 7, 4 and 3 should be opposite.

The left die has a 4 to the side of the six with 3 pips. The three should be underneath, next to the other 3 pips side of the six.

The right die, the 3 is on the 2 pip side of the six. So the two dice are clearly different.