r/explainlikeimfive • • 5d ago

Technology ELI5: How can you have non-deterministic programs if computers are deterministic machines?

294 Upvotes

373 comments sorted by

454

u/notacanuckskibum 4d ago

Computers often rely on non deterministic input from outside to create random behaviour. The speed of a user input is an easy example. One computer famously had a camera trained on a set of lava lamps to generate random numbers.

84

u/Zunderunder 4d ago

They still do. CloudFlare does that, currently, as one of its sources of entropy.

69

u/probability_of_meme 4d ago

I think it's important to note that OP said "non-deterministic programs" which we do not have. We get computers to generate non-deterministic outcomes by providing random input, but the programs are not non-deterministic.

59

u/dedservice 4d ago edited 4d ago • Heartwarming

Programs actually can be deterministic on each thread/core but in aggregate be nondeterministic. This is a classic problem in machine learning, because sometimes you'd like to have repeatable training programs where you end up with the exact same model output given the exact same training inputs. But by default, when doing parallel work on a GPU, even if each thread is deterministic, you simply can't predict how long each thread of work is going to take. When a thread of work completes, it takes its result and combines it with a running total (simplifying here). But floating-point arithmetic (i.e. adding or multiplying two numbers with many digits) is not commutative associative, because any time you do your calculation you have to round off the last little bit.  Meaning that if you add up your results as A + B + C, you'll get a different result from if you added A + C + B, because you'll have had to round differently each time. When you accumulate the little rounding errors from millions of calculations (and when each rounding error gets incorporated into the later calculations), you end up with massively different outputs for the same inputs.

14

u/pie-en-argent 4d ago

Quibble: Floating-point addition is commutative. The issue is that it’s not (precisely) associative.

2

u/dedservice 4d ago

Oops, yep.

4

u/grizzlor_ 3d ago

Teaching new programmers about IEEE 754 floating point was always fun (and a big “excuse me but wtf” moment for them). Had to explain this to a financial wizard with an Excel background who got into Python a few years ago. Had him open the Python prompt and type ‘0.1 + 0.2’. Result: 0.30000000000000004

Like yep bud, and that’s why you need to use the decimal package from stdlib for money calculations.

-1

u/Chess42 4d ago

While humans can’t determine that, it is still deterministic.

5

u/Borghal 4d ago

Deterministic by whose standards? Whether something is deterministic or not is based on the sum of the observers knowledge. The level of knowledge you're implying is close to omniscience.

3

u/Chess42 4d ago

Determinism is based on reality, not knowledge

→ More replies (6)

5

u/dedservice 4d ago

It's pragmatically nondeterministic. The variables you are able to control for are insufficient to reproduce a result. When discussing computational determinism, that is the discussion you're having. Claiming otherwise because "tEkNiClY" is not useful in practice.

But even outside of that, what you're arguing is basically a fundamental question of physics: With sufficient data, is classical physics sufficient to predict the future? As we've learned from quantum physics, the answer is, in fact, no. So you're still wrong.

4

u/CaseAKACutter 4d ago

Seems by your definition non determinism is only possible with superposition, which can affect things like minor differences in temperature which in turn effects processing time

4

u/thetrivialstuff 4d ago

Programs can be nondeterministic - on purpose if you're a really twisted programmer who disables data execution protections and creates a section of the program that uses a source of randomness to change itself as it runs. More commonly, they can be nondeterministic unintentionally if the machine doesn't have ECC RAM.

Fun fact: programs and systems become progressively less deterministic with altitude. An ordinary computer is unreliable at the top of a mountain (more so if it has a non-sealed spinning hard drive), more so in a plane, and if you put it in space outside of Earth's magnetic field, the computer stops being deterministic at all and its own behaviour is so unpredictable it can be used as a source of randomness.

1

u/charonme 4d ago

right, our actual programs aren't really non-deterministic, we just have it as a useful label for programs that are made to produce outputs determined by other additional factors than just its explicitly stated inputs

→ More replies (1)

30

u/OsmeOxys 4d ago

Sadly, the lava lamps are a PR thing and are technically a pretty bad source for randomness, though I assume the reality is "good enough". Your CPU already does a better job by monitoring electrical noise.

Funnily enough, you can generate more truly random output by literally just putting the lens cap on that camera and letting thermal and EM noise do their thing.

2

u/Notquitegravy 4d ago

They made a unique source of randomness as a security thibg

4

u/OsmeOxys 3d ago

Well... LavaRand was invented by SGI in the 90s, and that was actually used. CFs version is inspired by it, but isn't actually used as there are dozens of higher quality sources. It's really an art piece, which is cool too.

LavaRnd was developed by the original inventer. It was literally a camera with the lens cap on. That's it, that's the whole thing. It was a significant upgrade, and that's pretty damn funny.

262

u/LimerickJim 5d ago

You can't. Generating pseudo-random numbers is a whole branch of computer science.

47

u/MaybeTheDoctor 5d ago

There are real-random number generators for computer using things like radioactive decays as input.

14

u/orangenakor 4d ago

There are even chips you can add to a computer with a tiny radioactive source for generating randomness without a signal from the outside world that could be intercepted.

8

u/new2bay 4d ago

You can also use lava lamps as a source of entropy.

73

u/paholg 5d ago

You absolutely can. Not only do computers harvest entropy for random number generation, there are lots of other sources of (usually unintentional) non-determinism.

As soon as you have a multi-threaded program, you have to start working really hard to keep it deterministic.

22

u/cj6464 5d ago

That's only because of limitations imposed upon the specific program that's running. Theoretically, you can make it entirely deterministic on an individual computer if you instead tied program execution measurement to clock cycles and not time.

This isn't how it works in practice though, so for all intents and purpose it's non-deterministic.

18

u/LiamTheHuman 5d ago

I think you guys are arguing if reality is deterministic now btw.

-1

u/cj6464 5d ago

I think it is if you get really granular with your simulations.

4

u/paholg 4d ago

You can think that, but you should be aware that it's not based on any scientific results.

→ More replies (6)

1

u/RachelRegina 5d ago

It's deterministic, as you long as you take Everett seriously (and you should)

18

u/Michami135 5d ago

They're talking about how computers will track mouse movement, disk access, sensor tempratures, and sometimes even noise from microphones and cameras, they then hash it all together to get a pool of entropy to pull from.

4

u/duskfinger67 4d ago

But the software is still deterministic based on that input entropy.

The software will always spit out the same answer for the same input, we have just created an input that is always slightly different.

22

u/Michami135 4d ago

That's like saying, "If I roll 5 dice and add up their values, that method is deterministic because I'm using deterministic math on random values."

2

u/timour77 4d ago

Yeah or , "if I roll a die with the same speed, direction, on the same surface and everything else, I will get the same number"

→ More replies (1)

3

u/Crafty_Purpose_9566 4d ago

You’re missing the point. Look at your assumptions. One of them is wrong.

2

u/paholg 4d ago

No one has said a pure function can be non-deterministic; by definition, it can't be. 

A computer is not a collection of pure functions.

1

u/cj6464 5d ago

To a computer and for all intents and purposes, those systems are indeterminate, but with infinite precision in measurement and control of the system, they can be determinate theoretically.

13

u/db0606 4d ago

Except quantum mechanics at finite temperature pretty much precludes infinite precision measurements.

2

u/slicer4ever 4d ago

As a recording of physical process, quantum effects will prevent infinite precision in measurments.

2

u/EduardoBarreto 4d ago

Technically you can't have true randomness which is the point of the comment you're responding but you can have enough randomness to be unpredictable and thus truly random in a pragmatic but not literal sense.

3

u/paholg 4d ago

Yes, you can. Computers harvest entropy.

2

u/Far-Sky5160 5d ago

In a technical sense you can't generate random numbers using a deterministic system with deterministic inputs. You will need a stochastic source.

11

u/cBEiN 5d ago

Yes, this is what they were saying…

-1

u/Riokaii 4d ago

computers harvest entropy

at the limits of our knowledge of physics, these things aren't yet 100% deterministic by our understanding, but that doesnt mean they aren't "truly" deterministic in a "perfectly calculated or simulated universe" level. Entropy as input is still a program resulting in a deterministic output for a given input. Hash programs are just one example of deterministic entropy

4

u/paholg 4d ago

If you want to go by "perfect knowledge of the universe", you can't say a single fucking thing about anything. It's a meaningless framework to look at anything in.

8

u/SuperBelgian 4d ago

The reason why it is called "pseudo"-random is because it is not random at all. It only appears to be.

In fact, it is highly deterministic! Based on the same starting conditions (the seed) the generated pseudo-random sequence will always be exactly the same.

True random numbers can be generated, but depend on external input, which is not easily influenced. (Thermal fluctiations, keyboard/mouse input, radio noise, etc...)

59

u/Ecstatic_Bee6067 5d ago

You can. Modern CPUs sample environmental noise to generate truly random numbers

34

u/fantafuzz 5d ago

You cant though. The environmental noise is random. The computer itself uses that random input in deterministic ways.

All true randomness in a computer comes from outside the computer itself.

51

u/Ecstatic_Bee6067 5d ago

Which makes it random. That was the whole point of incorporating hardware instruction sets like rdseed in x86

0

u/fantafuzz 5d ago

The computer can sample random data to use, which is what instructions like rdseed does.

Whether your source of randomness is thermal noise, throwing dice and inputting the numbers, a wall of lava lamps or something else, the source of the randomness is outside the computer itself.

41

u/alldefector 4d ago

The question was how can we have random programs, not if the computer can generate random numbers by itself, and bringing an outside random source answers the question that was asked.

23

u/Raioc2436 4d ago

You come across as someone that knows things, and yet doesn’t understand them

4

u/Borghal 4d ago

If the sample was generated by the computer components themselves (such as thermal noise), then the claim that this is data outside the computer is obviously untrue, as it wouldn't exist without the computer running. The fact that it is merely a byproduct doesn't change that it is generated by the computer itself.

→ More replies (1)

8

u/jackster31415 5d ago

Is environmental noise random?

38

u/LennySMeme 5d ago

Yes. Even if the universe turns out to be deterministic we can't calculate it in advance so for all intents and purposes it is

0

u/SuckMyBallsKyle 4d ago

I think it has been proven that the universe is not deterministic

4

u/brandon1997fl 4d ago

It has not, there are mutually exclusive interpretations of quantum mechanics that differ on determinism.

2

u/SuckMyBallsKyle 4d ago

Not saying you’re wrong, but look at this other reply: https://www.reddit.com/r/explainlikeimfive/s/8i6pDv7PGo

1

u/e_dan_k 4d ago

It hasn't even been proven that the universe isn't your imagination.

3

u/SuckMyBallsKyle 4d ago

Yeah I guess you’re right. Quantum mechanics is definitely not deterministic though, and you cannot predict the positions photons hit on the double slit experiment. Though I guess it’s possible they are deterministic, we just can’t/don’t know where they will hit

4

u/Acebulf 4d ago edited 4d ago

I worked on this for my masters and taught a seminar on the subject. Photon pairs show statistical correlations above much greater than anything possible under determinism.

The nondeterminism we've measured is markedly different from something that behaves deterministically but where we don't have access to the information.

If there was a scenario where there was some predetermined knowable logic to photon state, but where we just didn't understand it or lacked some information, that world would behave differently from what we've measured.

This leaves a set of beliefs called "local realism" disproven. Either nature is nondeterministic, or information travels faster than the speed of light, or both. We know information doesn't travel faster than the speed of light, otherwise special relativity doesn't work, and that's been verified experimentally for over 100 years.

Ergo nature is nondeterministic.

→ More replies (4)

26

u/samurai-soulja 5d ago

to the extent that it matters, yes.

16

u/jackster31415 5d ago

But I think the question is intrinsically pedantic. Not in a bad way, just the question doesn’t ask “can we do something that is practically non-deterministic?” Is it we truly can make something really non-deterministic.

I guess for an ELI5 it’s hard to explain this, but any suggestions that we can are a bit disingenuous if we go deep down.

16

u/samurai-soulja 5d ago

agreed and it quickly turns into philosophy rather than computer science once you include room for this discussion

3

u/LuminousGrue 4d ago

If we go deep down, we can't ever know if something is random or deterministic. If I hand you the numbers 9999999, how do you measure whether those were generated randomly? You can't.

2

u/TheFrenchSavage 5d ago

If you can prove that we live inside of a simulation, then nothing is random.

Else, there's still a chance.

5

u/jackster31415 5d ago

Unless we’re in a simulation and the real universe does have real randomness. Then we’re back to square one

3

u/TheFrenchSavage 5d ago

Oh come on! Our simulation must have a seed.

I wouldn't want to live in a simulation that has true randomness, that's crazy. Get me out of this madhouse!

1

u/Borghal 4d ago

OP just asked how can you have a non-deterministic program. That's a quite clearly context-limited question, and since "deterministic" is more a function of the observer's properties rather than the process being observed, all you need is something that whoever is running the program cannot predict and the program becomes non-deterministic to them.

2

u/FernandoMM1220 5d ago

its not. not sure why people are saying it is.

5

u/Thick_Wasabi448 5d ago

Can you elaborate on that? Because there are things (such as radioactive decay) that appear to be truly random and ultimately result in macroscopic differences that affect these measurements.

→ More replies (18)

3

u/Ecstatic_Bee6067 5d ago

Depends what the noise source is. Quantum mechanics is inherently random

→ More replies (36)

1

u/Borghal 4d ago

Because you can't predict it, thus it isn't determinable. "I could if I was better" is meaningless as there's no proof it's possible.

1

u/FernandoMM1220 4d ago

its still deterministic even if you dont know how to predict it

→ More replies (4)

1

u/MaybeTheDoctor 5d ago

Geiger counter measuring radioactive background noise … which is actually real-world-not-pseudo-random.

Cheaper versions use mouse or keyboard activity.

4

u/R3M1T 5d ago

Not really 'environmental noise' because this implies some kind of sensor sampling external entropy. Instead, it is on-chip entropy - the CPU could be completely isolated from the external environment and still generate the same randomness.

3

u/Ecstatic_Bee6067 5d ago

Yes, there are hardware instructions that sample external entropy

1

u/R3M1T 5d ago

Intrinsic physical noise is not external

6

u/Ecstatic_Bee6067 5d ago

That's just a matter of how you define the system

→ More replies (5)

-3

u/mateusfccp 4d ago

Not truly random, though. Random enough, yes.

3

u/Cyclone4096 4d ago

TRNG chips generate true randomness based on quantum mechanical phenomena

→ More replies (1)

1

u/Ecstatic_Bee6067 4d ago

False. Computers have been able to generate true random numbers for some time

→ More replies (14)

1

u/coolio965 4d ago

it is truly random. X86 based Cpus have their own opcode for it.

https://www.felixcloutier.com/x86/rdseed

→ More replies (4)

1

u/DonnyDimello 4d ago

Sure, but if we're five, it's random.

1

u/ANewPope23 4d ago

Can't we keep some random physical system in the computer that generates something random? Physicists can sure come up with something.

6

u/tomrlutong 4d ago

We do, and it's been built into most cpus for about 20 years. 

2

u/EduardoBarreto 4d ago

All computers have various ways of having pseudo random number generation that's random enough for their purposes. Check the final paragraph from my answer to OP for some methods https://www.reddit.com/r/explainlikeimfive/s/cbvKiCTvPC

1

u/ANewPope23 4d ago

I'm talking about true random.

1

u/resilindsey 4d ago edited 4d ago

How random? Random enough for most programs/applications? Yes, easily. A common example (though a bit outdated), you can just use the epoch time in microseconds as the seed for a pseudo-random number algorithm. These days though processors have built into random number generators that use fluctuations in hardware like noise, heat, tiny timing differences in processes, etc. Which, maybe not random enough for Maxwell's demon, but random enough for us in 99.9999% of applications.

Truly random? No. The closest we have are machines that utilize superposition (which as far as we know are completely, truly random), but besides the fact that this would be incredibly expensive to duplicate in a personal computer, even these have some caveats because of possible measurement biases and environmental interference. Not going to explain fully here, but the "truest" random number generators uses cosmic signals to seed randomness for measurement settings in a series of Bell's tests to not only generate random numbers from superpositions but also verify that is it truly and independently random (well, as best as we can verify that currently).

→ More replies (1)

70

u/floon 5d ago

You try to generate random numbers. You end up with pseudorandom numbers, which work well enough for most things.

33

u/eudyptes 5d ago

While it was once true that computers only provided pseudorandom numbers, modern computers collect entropy to generate true random numbers.

-16

u/berwynResident 5d ago

It's not random if it based on something physical, unless it's quantum

45

u/Character_Cap5095 5d ago

the definition of randomness in a mathematical sense is that seeing any number of previous events does not impact your ability to guess future events. So chaotic systems are essentially mathematically random as they are uncomputable

4

u/Gagarinov 4d ago

If you define randomness like that then youre deliniating it from "deterministic". A coin-toss is random acc to your definition, but it's also deterministic (each outcome is determined by friction, force, materials etc). OPs question was about determinism.

1

u/frogjg2003 4d ago

If you can read all of the physical quantities that go into flipping a coin, you can predict the outcome too.

OP wasn't asking about philosophical determinism. OP was asking how a computer can generate numbers that is independent of any algorithm the computer can use.

→ More replies (1)
→ More replies (9)

5

u/mtconnol 4d ago

Thermal noise is essentially quantum, and a thermal noise source is built into many CPUs as a source of entropy.

10

u/force_disturbance 4d ago

It is actually quantum at the bottom.

7

u/eudyptes 5d ago

Some years ago I built a random number generator based on electrical noise, some of this noise is the result of quantum processes so it is random.

I would think a random generator based on precise tracking of mouse movements might pick up enough variability from electrical noise in the nervous system to be unpredictable.

4

u/WeCanDoItGuys 5d ago

Imagine a wild heist movie where they reverse-engineer how a computer makes cryptographic keys and they precisely controlled mouse movements and computer temperature and ram usage and everything else it might use to make the random key so that they can cause it to make a key of their choice and then rob someone.

3

u/vmf312corsair 4d ago

John von Neumann in 1951 remarked that "Anyone who attempts to generate random numbers by deterministic means is, of course, living in a state of sin."

22

u/BiomeWalker 5d ago

If the program changes behavior based on something outside of itself or the computer, like weather, temperature, current time, microphone sound, processor temperature, video feed, etc, then the results of the program will be non-deterministic.

4

u/graveybrains 4d ago

Doesn't really have to be outside exactly, they're already packed full of random noise that has to be filtered out for them to work properly. Race conditions are non-deterministic and they get their randomness from the structure of the processor itself and whatever noise is in it.

0

u/s-ol 4d ago

i wouldn't say race conditions are determined by the structure of the processor, or non-deterministic in the sense of OPs question. They are nondeterministic only with respect to the program experiencing them, because the ordering of multiple threads depends on the operating system's scheduling algorithm and what other programs are running and doing. Those things are out of control of the programmer, so to they have to be considered non-deterministic in the context of writing that single program.

But observing the running computer as a whole, it is a essentially a deterministic system (except for where it interfaces with the external world intentionally). You can look at any specific way that a race conditon works out and explain exactly why it happened, and why it had to happen that way, when you have that full picture.

1

u/SchwiftySquanchC137 4d ago

I mean idk how youre getting anything more than "why can running the same program produce different results?" From OPs question. Any programmer would say something is nondeterministic when you give the same inputs and get a different output, they dont mean "even with omniscient knowledge of the universe, no one could ever predict the output".

24

u/the_humeister 5d ago

You can if the program can take input from non-deterministic sources (e.g. lava lamps).

5

u/StageAboveWater 4d ago

Lava lamps are deterministic just technically infeasable to model

7

u/Riokaii 4d ago

this is the core misunderstanding people cannot seem to grasp causing the disagreement

4

u/ic33 4d ago

They are probably not.

They are chaotic. A tiny change to conditions along the way produces drastically different output minutes later.

And that "tiny change to conditions" can include things like nondeterministic quantum effects.

So you may be able to forecast a lava-lamp next to perfectly for the next several seconds, but ultimately the current state -- even if you could measure every atom-- is not enough to predict future behavior forever.

1

u/meneldal2 4d ago

More like you have no way of measuring the current state without changing it

1

u/ic33 4d ago

Aside from that: there's plenty of things that are, as best as we can tell, nondeterministic. In standard QM, even with full knowledge of quantum state, you only get probabilities.

For example, the actual thermal radiation entering or leaving the lamp: these are probabilistic processes; whether a photon gets absorbed, emitted, or reflected is up to chance. Or the radioactive decay of the 1 in 7000 hydrogen atoms in the lamp that are deuterium. Etc.

These will do effectively nothing in the short term, but make it difficult to forecast the state of the lamp hundreds of seconds from now, even if you could know everything about the lamp.

→ More replies (8)

2

u/SchwiftySquanchC137 4d ago

I think its more pedantry than disagreement. OP is basically asking "how could running the same program result in different outputs" and people are like "technically if youre fucking omniscient you can predict literally anything so it is deterministic". Let me tell you if youre creating a simulation for work and your boss wants it to be deterministic, what he means is "same input, same output" not "if you knew the state of every atom in the computer you should be able to predict the results". People are arguing if reality is deterministic, its just not what OP is asking.

2

u/dolche93 4d ago

You must be a psychohistory proponent.

2

u/EduardoBarreto 4d ago

If you wanna go far enough then yes randomness likely doesn't exist. At a macro level knowing the state of the big bang would let you predict the state of the galaxies and at the quantum level it may not be random at all, just impossible for us to precisely measure and thus random from our perspective.

So yes lava lamps are effectively random, more than enough if you can't know a precise enough state to effectively model its current behavior.

1

u/st3inbeiss 5d ago

Aaah finally the reference on the wall at Cloudflares HQ I was looking for.

0

u/[deleted] 4d ago

[deleted] — view deleted comment

7

u/CadenVanV 4d ago

Yes but they’re random enough for our purposes.

5

u/FiveDozenWhales 4d ago

To be fair, all computers are; the lava lamps are more about marketing than anything else.

2

u/VoilaVoilaWashington 4d ago

Sure, but it physics is deterministic in general, then it doesn't matter. They were always gonna use lava lamps and the criminal was always gonna find a way to get in anyway and the cops were always gonna find him...

If the universe is deterministic, then it's determined in advance that we're about to have this debate.

2

u/Jiannies 4d ago

Can’t something be deterministic yet still improbably difficult to compute? I’m thinking 3-body problem/entropy

4

u/vmullapudi1 4d ago

The three body problem is only hard to find a closed form solution.

You can solve n-body problem for arbitrary systems to under your desired error tolerance. It's just an iterative process generally instead of having a single formula you can plug in.

While many of these problems are chaotic (I.e., highly sensitive over the long term to small changes in the initial condition, if you can keep making measurements you can keep correcting your model- we solve multi-body problems to high accuracy all the time for spacecraft, astronomical modelling, etc.

For computational entropy purposes you generally want to leverage some source of random noise-theres noise in the least significant bit of sensors connected to the PC, noise from the user's mouse, or in this case for cloud flare noise in the camera system they're pointing at the lava lamp wall.

The wall itself is nothing special and isn't even a major proportion of the entropy cloud flare uses, it's just there to have the image be non-static

1

u/Fancy-Biscotti-6678 4d ago

Physics and reality are not deterministic. This is clearly demonstrated by quantum phenomena

2

u/dman11235 4d ago

Lol no. Multiple quantum interpretations are deterministic. Pilot wave is explicitly deterministic, and many worlds is pseudo deterministic. Copenhagen is the only one that's explicitly not deterministic. There are other ones but many worlds and Copenhagen are the only two that are heavily favored.

38

u/TimTwoToes 4d ago

Concurrency makes programs non-deterministic.

Two programs, A and B, reads the same file that contains the number 1. They both want to increase the number by one. Both programs run at the same time. It can have two outcomes.

The first scenario

  • Program A reads the file and read the number 1.
  • Program A increases 1 to 2 and writes to the file.
  • Program B reads the file and read the number 2.
  • Program B increases 2 to 3 and writes to the file.

The second scenario

  • Program A reads the file and read the number 1.
  • Program B reads the file and read the number 1.
  • Program A increases 1 to 2 and writes to the file.
  • Program B increases 1 to 2 and writes to the file.

So the contents of the file can either be 3 or 2.

Operating systems are highly concurrent.

16

u/codeOpcode 4d ago

The CPU scheduler is still deterministic so this is theoretically predictable. But practically speaking very difficult to predict

14

u/lookmeat 4d ago

The CPU isn't the only thing, your thread can be blocked on some external hardware system that will take some arbitrary and random amount of time, based on things like data corruption due to random EM fluctuations around the area you are, or a capacitor that is leaky and shoots at random intervals. CPU interrupts are not scheduled.

And even within the CPU, like I said random EM fluctuations and unique flaws within the hardware parts (which is a size you can count in number of atoms) and at some point the fluctuations and flaws can be triggered by random quantum effects. So it's not even theoretically predictable, there's things that are outright impossible to predict fully. Even assuming you have a Laplace demon in there.

1

u/JoeyJoeJoeSenior 4d ago

I'm thinking there's going to be some random quantum tunneling and cosmic rays causing errors that need to be corrected, thus making the timing less predictable. 

-1

u/TimTwoToes 4d ago

5 year olds and programs have no knowledge of any CPU scheduler.

3

u/MCWizardYT 4d ago

This subreddit isn't for literal 5 year olds

1

u/Borghal 4d ago

yes, hence the "like", but so what?

-2

u/SnugglyCoderGuy 4d ago

It does not. The scheduler is deterministic.

7

u/czdl 4d ago

Cores are sped up and slowed down independently nowadays, and so deeply pipelined and cached, that timing cannot be legitimately predicted without the use of external sensors. The scheduler may be deterministic, but when it comes to a contended resource (say, a shared piece of memory), order of access is not just not guaranteed, but is genuinely nondeterministic. This is why we have to use locks, memory fencing, the entire world of concurrent programming techniques exists, etc. A deterministic scheduler does not prevent race conditions. Oh how deeply I wish that it did.

6

u/thetrivialstuff 4d ago

The scheduler is only deterministic in extremely limited conditions, because interrupts exist and can happen at any time. The CPU does not control when network traffic arrives, when the user moves the mouse or types a character, when there is a blip on the power supply, or when a particular clock crystal vibrates very slightly differently because a neutrino or something went through it.

→ More replies (1)

11

u/BitOBear 5d ago edited 5d ago

Computers are not strictly speaking on deterministic machines. Most standardized CPUs are. But there are plenty of hardware random number generators that are stochastically random.

Some people argue rather philosophically about whether or not the universe is entirely deterministic at some level we cannot actually access but that's noise compared to what we're dealing with here.

But there are plenty of ways too measure non-deterministic effects and use those measurements to create randomness.

In fact there's a wall of lava lamps that have been generating high quality random numbers for the internet for decades now. But you don't have to go to that same extreme. There are chips that use hardware random number generator chips.

(Suggested search term: hardware random number generator chips)

Some CPUs in modern computers actually come with such features built in. All of the mainline Intel CPUs since broadwell, or I think one version earlier, have some form of hardware regular number generation built into them.

Even before that real world entropy was available. Linux kernels have used incidental Network traffic and keyboard event timing among other things as decently high quality digital entropy.

So your premise is somewhat flawed, CPUs that have real hardware entropy sources, secondary chips in the chipset that have real hardware entropy, and real world measurement of events such as digital images of random source material or network timing on non-trivially active networks can also produce non-deterministic events as available to the stochastic measurement of randomness in the universe.

A deterministic process built on top of a non-deterministic information source can produce a non-detriministic event stream.

When true random number sources are scarce it is not uncommon to feed those true random numbers events into a suitable random number generator as a series of continuously rotating seeds. Which produces random fragments from the pseudo random number generator data series.

And this can be amplified by letting multiple systems draw from common entropy sources.

For instance the /dev/random and /dev/urandom facilities in the Linux kernel allow multiple programs to be pulling from the same series. Since the two programs are not deterministically linked even poor quality sources can be amplified to sufficient randomness.

The quality of randomness necessary for particular tasks varies widely.

11

u/yueli93 4d ago

The sheer number of people in this thread confidently explaining things they clearly don’t understand is astounding.
Imagine asking a clown for a balloon. If you ask for a red balloon, he’ll pick out a red balloon and hand it to you. If you don’t specify a colour, he might simply hand you whichever balloon he happens to be holding. You could make the exact same request every day and receive a different coloured balloon.
Something similar can happen in C when you read an uninitialized variable. Instead of receiving a value you’ve explicitly assigned, you might end up reading whatever data happens to be left in that memory location. This is an example of undefined behaviour, which can manifest as nondeterministic behaviour.
You don’t need quantum mechanics or a fucking lava lamp to explain this.

5

u/account312 4d ago edited 4d ago • Bravo

Something similar can happen in C when you read an uninitialized variable.  Instead of receiving a value you’ve explicitly assigned, you might end up reading whatever data happens to be left in that memory location

And that's if you're lucky. The compiler might send a clown to burn your house down instead if it thinks that would be faster.

8

u/InsidePossession5327 4d ago

I mean it's undeterministic in the scope of the program, but if you knew every program that ran before on that computer, you would know what the uninitialized memory contained.

3

u/yueli93 4d ago

Knowing which programs previously ran is nowhere near sufficient. You’d need the complete machine state, execution history, memory allocation history, thread scheduling, interrupts, etc.
Furthermore, undefined behaviour in C means the compiler isn’t even obligated to allocate memory for that variable.
You’re conflating determinism at the hardware level with determinism at the program level. The former does not guarantee the latter.

5

u/ChangeMyDespair 5d ago

Race conditions.

The name captures the problem exactly: the operations are racing, and whoever wins the race determines the outcome. Because that ordering is non-deterministic, race conditions produce bugs that appear intermittently, pass in testing, and surface under production load.

(source; bold emphasis added)

1

u/BraveNewCurrency 3d ago

Yes, but... This didn't answer the question, it just gives some background.

Why is the ordering non-deterministic? ( if computers are deterministic )

4

u/TechnicalBreakfast59 4d ago

Not quite ELI5, but maybe understandable given your post history:

In terms of non-deterministic vs deterministic Turing machines, the simple answer is the latter is a theoretical construction. It does not exist in the real world.

Imagine you're solving a problem to find any prime factor for a number N. In a deterministic Turing machine, you'd loop from 2 to N-1 to find some prime number that factors N. In a non-deterministic Turing machine, each number from 2 to N-1 would be tested at the same time to see if it is a factor. 

You can see that the former algorithm is in O(n). The latter, however, is in O(1) because there is no need for a loop. It tests all possible states simultaneously in their own "branch". The existence of these "branches" is why we refer to the machines this algorithm runs on as non-deterministic.  Non-deterministic Turing machines can be simulated on deterministic ones, but the time complexity of algorithms would increase exponentially. Each branch would be executed sequentially rather than parallel.

Note that on a deterministic Turing machine, it is trivial to check if your found prime factor is indeed a prime factor (N % F == 0 is in O(1)). Problems like this are considered to be in the set NP, which is all problems that can be solved non-deterministically in polynomial time, but maybe not deterministically in polynomial time. However, the solution to these problems can be checked deterministically in polynomial time. A way to think of non-deterministic algorithms is they test all potential solutions simultaneously to find a valid one.

Problems that are NP-complete means that any other problem in NP can be written in terms of the NP-complete one. If you find an algorithm to an NP-complete problem (like 3SAT) that runs deterministically in polynomial time, you've shown that P=NP. 

1

u/whatisuser 4d ago

ELI55

1

u/MrQuizzles 4d ago

Imagine solving a maze. When a Turing Machine hits a juncture where it can go multiple ways, it has to go down them one at a time. Then the next time it hits a juncture, it can only take one path, and so on and so forth. Imagine a singular line tracing its way through the maze and backing up whenever it hits a dead end. In a complicated maze, it can take a long time for this singular line to solve it and find the shortest route if there are multiple.

When a Non-Deterministic Turing Machine hits a juncture where it can go multiple ways, it basically just clones itself and takes all possible paths at once. So instead of a singular line, there becomes many multiple lines. It solves the maze much faster.

1

u/beeskness420 4d ago

Small nondeterministic computational models exist and have been implemented in the real world. The catch is that they use exponential space/parallelism. For example DNA based string rewriting models.

2

u/WeCanDoItGuys 5d ago edited 5d ago

You can generate a list of random numbers from some truly random source and then iterate through that list on your computer.
Truly random could maybe be some measurement of some quantum particle.

Python's random module uses a deterministic algorithm called the Mersenne Twister, that generates pseudorandom 53-bit floats and has a period of 2¹⁹⁹³⁷-1.

The Mersenne Twister is one of the most extensively tested random number generators in existence. However, being completely deterministic, it is not suitable for all purposes, and is completely unsuitable for cryptographic purposes.

For cryptographic purposes:
Get one random number from the noisy world around the computer (based on mouse movement, RAM usage, temperature) and use it as a seed in a deterministic algorithm to generate more random numbers. If the seed is unpredictable, it's acceptably random, at least to say National Institute of Standards and Technology (NIST) if not to theorists.

2

u/MeasureDoEventThing 4d ago

It would help to know what context you're talking about. The term "non-deterministic finite automaton" is used in mathematics/computer science as a mathematical abstraction that isn't necessarily implemented on any physical hardware. We can talk about the mathematical theory of non-deterministic variations of a Turing machine without actually having a non-deterministic computer.

4

u/A17Massey 5d ago

It only takes a very small amount of manipulation of numbers to get something that while not "non-deterministic" but impossibly unpredictable

A very simple random number generator might take the computer's system clock in fractional seconds to 6 significant digits (e.g 59.047324) and apply some basic calculation to it. That number is entirely unpredictable, but as "random" as science needs for every reasonable application

2

u/PhilNEvo 5d ago

It depends on what you count as "non-deterministic". For example, pseudo-random number generators, can often take a seed, and if that seed is somewhat "random", you would not be able to predict the number coming out. Let's say the seed was based on time + your mouse position when you ran the program. While everything that happens once the program starts, because the starting conditions have been set, will be deterministic, it will feel non-deterministic, because it's difficult to repeat the exact circumstances that brought about a certain result.

2

u/Atypicosaurus 4d ago

Deterministic is different from predictable.

You don't say it out but I believe you might refer to various AI models. AI models such as LLMs are deterministic.

However they are different from "normal" programs in two ways.

One is, simply saying, LLMs write themselves. You have a defined starting state and defined rules to write over their own starting state. The rules for this overwrite is deterministic but the variables to overwrite is in the billions. And so even if we could analyse the final state, it would be a numeric gibberish, we don't know which numeric value on which of the billions of variables do what.

And two, LLMs are extremely complex as a program, but each of those billions of values have a very little contribution to the whole. Just like with an actual biological nervous system, one neuron cell doesn't change anything if you lose it, LLMs would also probably not change by taking out a few of those values. So it's actually not really a way to investigate what part does what, not that we can manually write into it but even if.

And so what you experience as AI being non deterministic, it's just too complex to predict and assess. I hope this answers your question.

2

u/Fenjen 4d ago

Many answers miss the point, even when they’re technically correct in some sense. This partially stems from wrong understandings of probabilities.

The funny thing is, every day, literally any moment you use your pc it does "non-deterministic" things. Nobody can perfectly predict what your computer or phone is gonna do before you use it, simply because they can't predict what you're gonna do perfectly. You interact with your pc at "random" moments in the day and ask it to respond to whatever you input. The exact behavior of the computer at the exact time it does so follows from your input.

Random behavior in an autonomous program can work in a similar way. We could measure cosmic rays from the universe, input it as a number that decides part of the behavior of the program and have unexpected results every time. Since it's impossible from a practical point of view to predict cosmic ray patterns.

The problem is, that if you know the state of the computer well enough (i.e. all the numbers that went into a program, or piece of code), and also that number from the cosmic ray, once it was recorded and input into the computer, and perhaps even the exact time it went in (since clocks can also be used for randomness generation, since it's typically hard to know exactly when a program will run), then the programs can become deterministic.

Determinism vs non-determinism depends mostly on your point of view and what you know about what went into the computer.

Sometimes it's even possible to deduce numbers that you didn't know before by observing the patterns that a computer makes for long enough. If a program is made to output random numbers by some known algorithm, starting from some random number that you don't know, we could start observing the numbers that are output: 1, 61, 111, 9, ... . Depending on how the algorithm was written, and how much other randomness we introduce along the way, it may be possible to say something like: give this program, and the sequence we observed, that could only have been produced if the starting number was 7. From that moment on you can keep predicting the program.

1

u/Sulleyy 5d ago

Are you asking about LLMs specifically?

LLMs essentially determine a probability distribution of what it predicts the next token should be. Then it introduces some randomness to choose an actual response based on the probabilities. So the same prompt may have the same result in terms of the token probability distributions but will randomly choose the exact response

1

u/fenton7 5d ago

Most modern CPUs have random number instructions that sample hardware noise in a non-deterministic manner. Many algorithms leverage this to achieve behavior that is not predictable. In addition, modern GPUs execute a very large number of instructions in parallel and the ordering of results is not deterministic. So for a very complex application like an LLM the effect in most use cases is that each output is unique and not reproducible.

1

u/CropCircles_ 5d ago

A computer rng is always fundamentally deterministic unless it relies on quantum rng

1

u/Ruined_Passion_7355 5d ago

Most non determinism comes in the form of bugs when something goes wrong. As an example, a program attempts to read memory it shouldn't, what does it read? Depends on what the user was doing beforehand.

Or what about race conditions, where the result of a program depends on which thread got there first. That's non deterministic because you basically can't predict which thread will go first, it's up to the whims of the scheduler.

There's also using non deterministic input as a seed, but that's cheating ig by your definition.

1

u/jwadamson 5d ago

By measuring something outside the computer. This could be a dedicated randomness chip or timing various events with the network or user.

1

u/AMWJ 5d ago

The same way you can have non-deterministic anything: you can't.

Or, alternatively, you simulate it with deterministic processes that are beyond prediction..

Or alternatively, you simulate it with mathematical processes that are believed to be "one way", and therefore unpredictable.

Or, alternatively, you build specialized mechanisms to utilize what we currently believe to be random physics effects to get a "truly random" effect.

1

u/CalmCalmBelong 5d ago

It is possible to have a chaotic algorithm executing in a deterministic machine. For example, a physical simulation of a chaotic system: the noise due to bignum truncation can be sufficient to amplify the chaotic behavior (measured with a positive Lyapunov exponent) to observable levels.

1

u/stonerism 4d ago

Non-determinism is just a way of making modeling computation easier, but it doesn't actually give you more computing ability.

1

u/blamestross 4d ago

We talk about computers being deterministic "in theory". They have to be made in real life by real people and of real materials.

Nondeterministic behavior comes up in a few places:

  • multiple programs running at once started with timing differences. The operating system can decide to run chunks of parallel code in different orders.
  • hardware faults (literally cosmic rays and just heat entropy) which can lead to delay and inconsistency in how long an operation takes.

That ideal "deterministic computer" got started by a messy non-deterministic human and build out of messy rocks in a universe shooting cosmic ray bullets at everything.

1

u/exipolar 4d ago

The things we tend to call “non-deterministic” really come down to the application having no control over its inputs, often by necessity.

IMO, The term “deterministic” is kind of a misnomer outside the realm of setting customer expectations. In practical terms, most programs are almost entirely deterministic in function but non deterministic in application.

1

u/DTux5249 4d ago

This is the difference between true & pseudo randomness.

True randomness is 100% nondeterministic. Most computers don't do that, because it's hard if not impossible to do.

Pseudorandom means "hard enough for a human to predict as to be good enough for random". Pseudorandom numbers can be taken from any number of inputs - typically your system's clock - which you can then plug into algorithms to make a long number that's as good as random.

Most "nondeterministic" programs are totally deterministic using pseudorandom numbers. You can 100% predict what's gonna happen next if you know your computer's current state. But if you approach a game like a game, odds are you aren't gonna do that.

1

u/Helpful_Hawk3556 4d ago

You can have a program pull a value from a non-deterministic source (let’s say a sensor that detects the decay of a radioactive element) and inserts that variable into An algorithm. Bing-bang, there you go: randomness!

1

u/falconfetus8 4d ago

Multithreading. If two threads are running simultaneously, it's not predetermined which one will finish first. If those two threads are reading and writing the same memory as each other, then the final state of that memory will depend on the exact order in which each thread's instructions interleave. That order can be jostled by pretty much anything, including(but not limited to):

  • The other programs that happen to be running on the PC
  • Interrupts caused by user input
  • A butterfly flapping its wings on the other side of the planet

At the speeds computers run at, any kind of stumbling block can cause a slight variation in timing. Hence, it's safest to assume that anything involving more than one thread will have some unpredictability to it. And yes, it makes debugging nightmarish.

1

u/rebornfenix 4d ago

The code running programs is deterministic, however we have ways to generate pseudo random numbers to get the appearance that they are not deterministic.

What does that mean? We have fancy programs that take a seed value and then run a specific algorithm on that seed value to return a number.

If we have a program that outputs the result of X + Y, the same values of X and Y will always produce the result Z. That is deterministic.

However if we want to add a non deterministic value to X, we use a random number generator to fill in Y so that if we pass the same value for X to X + RandomNumber we get a different value for Z.

However even that can be argued to be deterministic if you know the internal state of the random number generator.

For applications where being deterministic is a very bad thing (like cryptography), we use non deterministic physical input to seed a random number generator so that from an attackers point of view, it’s completely random because there is no way for them to know what the current internal state of the random number generator is.

When we build applications that become ever more complex and use random numbers in several places, the amount of information to keep track of for the system becomes effectively non deterministic.

This gets into a classic physics philosophy of “If you know the input conditions of every atom in the universe, is the universe deterministic?”

At some point, for humans, the universe becomes non deterministic because we will never be able to know the input conditions to a detailed enough extent for the system to become deterministic.

1

u/SaltCusp 4d ago

Sometimes computers compute multiple things at once and it isn't certain which of those things will compute first. This is commonly referred to as a race condition.

Seperatley computer programs can get data from sensors and the values from the sensors are not predetermined. As a matter of fact the computer itself is something of a cosmic ray detector.

1

u/Ben-Goldberg 4d ago

if you power off some SRAM, then power it back on, the first time you read it will give you a random number.

This type of random number will have a bias depending on the physical layout of the circuit, which makes it impossible to generate a lot of random numbers and use a cryptographically secure hash function to compensate.

If you repeatly read the value of a specific (just powered up) SRAM bit, and you know that the values are biased but not correlated, you can use more efficient unbiasing that doesn't throw away as many bits (e.g the Perez randomness extractor).

My personal favorite way to convert biased bits into unbiased bits is like this:

extern unsigned int get_biased_bit();
int get_unbiased_rand() {
  static unsigned int state[2] = {0, 0};
  static unsigned int buffer = 0, count = 0; 
   int i;
   assert ( count < 16 );
   again:
   for( i = 32-count ; i-- ; ) {
     unsigned b, m, out;
     ++state[get_biased_bit()];
     b = get_biased_bit();
     ++state[b];
     m = state[0] & state[1];
     out = !!m;
     buffer <<= out;
     buffer |= b & out;
     count += out;
     assert( popcount(m) <= 1 );
     state[0] -= m;
     state[1] -= m;
  }
  assert( count <= 32 );
  if( count < 16 ) goto again;
  count -= 16;
  return 0xffff & (buffer >> count);
}

It is a compromise between von Neumann unbiasing and Perez unbiasing, being more bit efficient than the first and more computationally efficient than the second.

Minimizing branching based on random values avoids making the branch predictor excessively unhappy.

There are some unavoidable unpredictable branches - the for loop runs (randomly) between 16 and 32 times, and whether or not the for loop is repeated is also random.

1

u/gutentight69420 4d ago

You include sufficient random inputs to your deterministic program to make the output unpredictable. 

1

u/Pndapetzim 4d ago

Well, we're not even sure our own brains are deterministic.

You can create something like a system calculating multiple mutually interdependent variables, if you do you you wind up with probabilistic outcomes.

These can be, technically deterministic, but incalculable.

This leads to a deterministic system that can output numerous potential outputs with no way to predict which, except through probabilistic methods that can only tell you the likely frequency of an output occuring over a distribution curve.

1

u/AutobanThrowaway 4d ago

You can't, so you just make the determination really hard to find and abuse. Lazy programs use your system clock, more advanced ones use a wall of lava lamps.

1

u/Vegetable-Phrase7843 4d ago

Like others have said, for the most part, you can’t. People have created algorithms that produce random-seeming (pseudorandom) results in a deterministic way.

The rare exceptions are using physical systems like lava lamps for sources of randomness. Whatever you’re thinking of is probably not using this, though.

0

u/VegasBedset 4d ago

The rare exceptions are using physical systems like lava lamps for sources of randomness. Whatever you’re thinking of is probably not using this, though.

Lava lamps are 100% determinstic. There is nothing ransom about them at all.

1

u/Borghal 4d ago

I bet if I put a lava lamp in front of you, you won't be able to determine it.

See, I can ignore context too :-)

→ More replies (5)
→ More replies (3)

1

u/Classic-Rate-5104 4d ago edited 4d ago

Many things in a computer are not deterministic. The temperature, the exact time the user starts a program, the timing of physical drives, the external power fluctuations. Some of these factors can influence the order of some (concurrent) operations or even the speed of some components of the computer

→ More replies (33)

1

u/TheRussianPigeon9715 4d ago edited 4d ago

Most programs are deterministic even if they seem not to be. Most of the time when we need something "random" we use a pseudo-random number generator (PRNG), which is a type of entirely deterministic but highly irregular function that returns effectively random numbers based on input (the input is called the seed, most commonly the system's time since epoch)

If we need genuine non-determinism we can use non-deterministic systems in real life for data. Most famously, Cloudfare uses lava lamps for their encryption. If you visit their HQ lobby in SF they even encourage you to check them up close since it adds more noise into the data!

However they didn't even stop there. In their London offices, they use double pendulums for their encryption

1

u/iqisoverrated 4d ago

You can get non-deterministic outcomes pretty easily with race conditions. Debugging stuff that happens seemingly randomly is your bread and butter in man complex software system. The behavior of your program depends on the state of your ghardware (and that can depend on such weird things as temperature...or just how other programs running at the same time behave)

1

u/jared_number_two 4d ago

It’s like saying “why do we say these speakers are deterministic when I can turn the volume knob whenever I want.”

1

u/VegasBedset 4d ago edited 4d ago

You can't. There is no such thing as true random. It's all psuedo-random.

If you knew the exact physical state of every variable that impacted the "random" result, you could predict it with 100% accuracy. People just like to call things "random" when what they really mean is "sufficiently difficult to determine to be considered random" aka psuedo random

Nothing in the physical universe above the Planck scale is actually random. The only random effects in the universe are quantum effects

1

u/EduardoBarreto 4d ago

If a computer wants to use randomness it uses a pseudo-random number generator as the input of the randomness function known as a seed.

A randomness function is one that has crazy variance in its output for any series of seed inputs, like entering 2 outputs 100 then 3 outputs 5 then 4 outputs 31 etc. It's basically unpredictable if you can't predict the seed that was entered.

I just told you that to make randomness you need randomness which is a "Thinking quickly Dave made a megaphone using rope, a squirrel, and a megaphone" moment but it's because sometimes programs want to reuse their randomness seed, particularly often in games. We also make this distinction as a way to abstract the source of randomness away from its usage, if you assume the seed is always truly random then you can safely assume that any function that uses it is also truly random.

And how is the seed generated? A number of factors, sometimes simply using the time of day is enough if you don't need that much security. User input is also a usable source for similarly low security applications, it was often generated in the start screen where you need to press something to start the game and it was often exploited by pressing it in specific moments for speedruns. Then if you really need randomness for security purposes things like electrical noise, hardware interrupts, slight thermal variations are used either by querying all of the sensors and activity visible to the operating system or by leveraging dedicated randomness components in a CPU. And if you need even more randomness you can use sensors and external phenomena such as Cloudflare's camera pointing at the famous lava lamp wall or weather patterns, radioactive decay, and more.

1

u/clippy_is_a_prick 4d ago edited 4d ago

Assuming this is in reference to AI

It isnt literally non-deterministic, its just so complex (as in theres billions of interactive parts) that all feedback into each other it would require so much effort to predict it is practically non-deterministic.

Think of it like a massive grid of light switches stretching for miles, every time you flick one, the rest of them all react and change position, and every time you repeat the action it actually changes the order the switches change. Theres clearly some relationship between the switches, but figuring that out would take so long its not feasibly possible.

In this analogy, the light switch grid is the model of the AI, and flipping of a switch is essentially processing a token, a token for simplicity is a word.

The way the model (the light switch grid) is configured is determined by training, which is essentially pushing a huge amount of tailored data (think petabytes) through an program which designed to configure the grid. This process determines the models behavior and again due to the amount of data and the complexity of the configuration is practically non-deterministic.

1

u/BaggyHairyNips 4d ago

If you want randomness you start with a "random seed" number then feed it to a function which generates more pseudo-random numbers based off that seed.

The function will output the same thing every time you give it the same seed. But it's designed so you can feed back its output as its next input and it will give you a series of unpredictable numbers.

The seed might be something like the current time, or a value generated based on the user's mouse movements, or a camera looking at lava lamps.

It's not truly non-deterministic, but it's unpredictable.

1

u/Same_Square2555 4d ago

introduce pseudo randomness

LLM's always have the parameter for randomness

1

u/bildramer 4d ago

You are almost certainly asking about nondeterministic programs in the P=NP sense, something 99% of these idiot commenters missed (while confidently repeating LLMslop and telling you that everyone else missed the point). In that sense, it just means "instead of taking one paths take all paths, and if any finish, you're done". It's a purely theoretical construct, unless reality is truly absurd and P=NP.

1

u/KvThweatt 4d ago edited 4d ago

All these answers saying it’s deterministic act like all variables are known at all times including the positions of all atoms and every quantized unit of energy. Get real here, the guy wants a simple explanation.

Basically, think of it like combinations. How many different ways can you arrange all the instructions a computer has? That alone is a very large number. Then you have loops and repeated sequences. All together, you can continue to add more instructions until you run out of memory to hold them all. Whether any of these combinations do anything useful is dependent on what the result of those instructions are. While the number of instructions is finite, the way they can be put together is basically infinite. The larger the program and longer it’s running the more likely you won’t know how it will end. Anything could go wrong, instructions can change their order.

1

u/alphakazoo 3d ago

The question should probably be rephrased to get a decent answer. As stated it’s kinda like asking how can a bird shit on me if I follow the AA’s 12 steps to recovery.

I think you might be asking about “how can we actually have randomness in a computer program if the underlying hardware should be repeat the same calculations and come to the same answer” but that’s not what non-deterministic usually means in relation to programs so it’s making people conflate the two in their answers.

Truly though, we can have non-deterministic programs on a deterministic computer if we program them as such. If you program something to expect user input, then it is now non-deterministic (from the program’s perspective) as it is incapable of determining whether or not it will finish because it cannot see the future to see if a human will interact with it before it is terminated.

2

u/rhelg224 3d ago

You can buy a bird and lock yourself and the bird in a tiny room. It won't take long.

1

u/Yamidamian 3d ago

Because programs receive inputs, which might not be deterministic-at least, not in the sense of being determined purely by the computer’s actions. So, while you could determine how the comouter will act for a specific input, determining how it will act in a vacuum is impossible, because there’s not enough info. You don’t know what a video game will do u less you also know what the player does.

1

u/norude1 3d ago

you can request something from the internet for example

1

u/Mayor__Defacto 2d ago

You can’t. That’s why true randomness is such a difficult problem; the best we can do is pseudorandomness. You use a deterministic algorithm, and make it ‘random’ by using something variable as the input that you don’t have control over.

1

u/gutclusters 5d ago

Though modern hardware random number generators can effectively produce non-deterministic numbers, the reality is that there could be a flaw that can make those numbers predictable. Applications that need true randomness tend to seed from external sources. For example, Cloudflare famously uses cameras pointing at a wall of lava lamps to produce seeds, though they also use radioactive decay, pendulums, translucent rainbow colored mobiles, and a wave machine as seeds as well. Other source examples are radio noise, seismic activity, and activity on block chains.

0

u/shiba_snorter 5d ago

I think you are mistaking non-deterministic problems with non-deterministic programs. You can have problems that are ND in their nature, but if you want to solve them you need to approach them in a deterministic fashion.

0

u/Cracky712 5d ago

You cannot but you can come close by using thermal noise from the heat sensors as an input or another famous example is the cloudflare lava lamp wall.

-1

u/Alib668 5d ago

Just like a cricket match or chess match everything in itbis deterministic, based upon whatbis the best play at that moment and a known rule setbthat is comple.... doesn't mean each game plays out exactly the same because you make different choices based upon what you deviding against aka the other side.

Secondly we nake random numbers from lava lamps because anything else isnt really random is things like the state of the cpu atvthat exact second

0

u/MasterGeekMX 5d ago

That's the key: you don't.

What most computers do is fake it with a formula. First, the computers grabs a number, either by taking something like the time or asking the user for one, and then applies a formula to it. The result of the formula is the first random number. If you ask for a second random number, the computer will take the first one and shovel it inside the formula. If you ask for a third, then the second is chewed by the formula. Rinse and repeat.

This means that you can predict all the random numbers by simply knowing the formula and the starting number (called the seed on the lingo). The key is the formula: there is a ton of work on making that formula so you cannot predict the sequence easily by looking at the numbers.

For more serious stuff, you attach to the computer some device that measures something physical that is random. Some servers use a small piece of radioactive material, and use the time between radiation blasts as the random numbers.

0

u/obog 5d ago

By sampling something external that is non-deterministic. Famously cloudflare has a shelf full of lava lamps theh use to sample truly random numbers from.

0

u/Love_Calculators 4d ago

in addition to things everyone else has said, there's the idea of race conditions. most computers have multiple cores that are separately executing instructions, so (in a simplified example) say both cores try to execute a print statement simultaneously, which one shows up first depends on how quickly the underlying hardware on each core can execute that instruction.

0

u/LawFluid1931 4d ago

I think OP is referring to machine learning.

0

u/Bogdan_X 4d ago

You can't. The program is always deterministic, but the output, in case of LLMs is not.

0

u/Dovaldo83 4d ago edited 4d ago

It's common in programming to set up a loop that continues while some condition is true. This is called a while loop.

Write a program that keeps doing a while loop while a condition that will always be true is true, like while 1=1. Instead of ever ending, the program will go on for as long as it is allowed to run. Congratulations, you just set up a non-deterministic program (and possibly froze your computer).

It's not that this program isn't deterministic in the sense that it's set starting condition won't always arrive at it's predetermined result. It's just that this particular result is to keep on going and going without end. It'll never determine an answer to anything.

There are a set of problems who's solutions are non-deterministic, in that we don't know if the program needs more time to process the solution or if the program is stuck in an infinite search for the solution it would never arrive at. For instance, if I set up a spacecraft with infinite power to go search the infinite universe for a teapot that didn't come from earth, that would be a non-deterministic problem for it to solve. We have no way of knowing if it needs more time to search or will never find a teapot.

0

u/deadly88 4d ago

A PRNG isn’t deterministic, but you can “seed” it with any integer, and it will have a very different sequence even with seeds that are similar. It achieves this generally with a few cheap operations with fairly large prime numbers that make patterns hard to detect.

A common strategy is to set the seed with the number of milliseconds since some epoch (often 00:00:00 on jan 1st 1970 aka unix time) and it will be random enough for most cases, since it will have very different results even if it starts 1/1000 seconds apart.

If you need true randomness, some modern systems have a quantum RNG instruction, which is generally used to seed a PRNG. Prior to that can use external sensors like the famous lava lamp walls, which in theory could be deterministic, but they are way too complex to be simulated.

0

u/nednobbins 4d ago

There are 3 main parts.

Computers have an internal, system level, function called seed(). That lets it store a really long number. This can be anything as long as it's hard to guess. A common number is the date when the computer was last booted, in seconds.

They also have an internal, system level, function called rand(). The main thing it does is put seed value through a deterministic function that changes it a lot. It basically shuffles everything around; it's still deterministic but the important thing is that there's no known way to undo it. For example, take a 20 digit number, square it, and drop digits from the right until it's back down to 20 digits. That's fairly easy to do but really hard to undo. rand() spits out that new number and sticks it into seed().

Now any program that wants something random can just call rand(), which essentially hands you a giant random number and then modify that number to get it into the range the program needs.

Note: The exact function names and algorithms differ, but that's the basic idea.