r/explainlikeimfive • u/nanoman1 • 5d ago
Technology ELI5: How can you have non-deterministic programs if computers are deterministic machines?
294
Upvotes
r/explainlikeimfive • u/nanoman1 • 5d ago
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.
262
u/LimerickJim 5d ago
You can't. Generating pseudo-random numbers is a whole branch of computer science.
70
u/floon 5d ago
You try to generate random numbers. You end up with pseudorandom numbers, which work well enough for most things.
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.
24
u/the_humeister 5d ago
You can if the program can take input from non-deterministic sources (e.g. lava lamps).
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
The second scenario
So the contents of the file can either be 3 or 2.
Operating systems are highly concurrent.
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/ChangeMyDespair 5d ago
Race conditions.
(source; bold emphasis added)
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.
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.
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:
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):
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:
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.
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
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.
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.