How Computer pick a random number 🤔? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

How Computer pick a random number 🤔?

Computer doesn't have a brain like human. So they don't have an ability to think. So how do they pick a random number 🤔.

24th Dec 2021, 8:53 AM
Mohammed Nihal
Mohammed Nihal - avatar
12 Answers
+ 8
That's a great question! The truth is it's not possible to generate an authentic random number, but instead computers can generate pseudorandom numbers via mathematical algorithms and current time, which may simulate randomness and are good enough for most uses.
24th Dec 2021, 8:58 AM
skaltecho
+ 7
Answers given are correct. But I would disagree with one fact that was told by skaltecho . It is not "yet" possible to generate real random number. As it is not mathematically proved yet. But if you would find a way to do it then you will change the whole information technology =)
24th Dec 2021, 9:58 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 6
Martin Taylor it seems like you've just wrongly read my message. It's okay. I was talking about mathematically proved function which would "generate" random numbers. Please do not be toxic on this platform as it may lead to report.
24th Dec 2021, 1:38 PM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 5
Martin Taylor Unfortunately you've just wrongly read my message. But it's okay, just keep in mind that you don't need to be toxic. =)
25th Dec 2021, 12:11 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 4
Martin Taylor , My answer was a really quick and basic answer but thank you anyway.
24th Dec 2021, 2:17 PM
SoloProg
SoloProg - avatar
+ 4
In fact, humans can't come up with random numbers too! It may be surprising, but think of it once, if we are asked to tell a random number, we don't say a random number, but instead we say something which appears to be random for the asker and ourselves. True randomness doesn't exist, atleast not in this universe. Even if you roll a die, you can exactly predict it's outcome if you have superhuman intelligence and speed. Just like the word "perfect", the word "random" too is used to describe how random looking a thing is, but doesn't actually exist. Specific to your question, we program computers to do just the same we do for coming up with random numbers. For example, you can create a function, f(X)=(5565 × X) + (89 × X²) % (992345 × X) You can implement this function to get one input (or can be called a "seed") and output the calculation of the function. For a person just looking at the output, they will most likely think it's a random number generator function and say that you're intelligent.
26th Dec 2021, 2:15 AM
Rishi
Rishi - avatar
+ 4
For a ture hardware random number generater you can use the time between decays in a sample of a radioactive isotope. The time between clicks of a gigercounter. If quntum mechanic is correct the the time it take each atom to decay is truly random.
26th Dec 2021, 7:26 AM
Rick Shiffman
Rick Shiffman - avatar
+ 3
By default the random number generator uses the current system time. Keep learning & happy coding :D
24th Dec 2021, 8:58 AM
SoloProg
SoloProg - avatar
+ 3
Some times it more useful to have a psudo-random number generater when debugging code that wants random input data because you can Use the same seed to generate the same sequence for diferemt versions of the code your working on.
26th Dec 2021, 7:38 AM
Rick Shiffman
Rick Shiffman - avatar
+ 2
Sometimes the hardware measures the physical environment around it, light, heat, vibration, and allows it to interfere with the data. Again, the effect is the same, the seed is easily generated by measuring the environment. What's *difficult* is recreating the same seed from an environment that only exists around one computer at one time. I personally don't think human consciousness is immune to this, and I don't think we're all that different from computers in that regard.
25th Dec 2021, 8:39 PM
DeAndre ReiChelle
+ 2
I personally think a computer can not generate a random number but can only simulate the process of randomness. Randomness requires the ability to think. I believe as long as something can be predicted then it is not random. As for TRNGs there is a billion billion chance of number repetition for 10 random numbers whereas if you were to ask a human being for the same there wouldn't be any repetition. Just my thoughts people.
25th Dec 2021, 11:59 PM
Nkosilamandla Halimana
Nkosilamandla Halimana - avatar
+ 1
Seems like a philosophy question. I always just assume the concept of randomness means little in the world of classical computers. The appearance of computerized randomness usually comes from mutations on data sets that are easy to cause in one direction, but extremely difficult to undo. For example, consider multiplying two large primes together. Easy enough with a pocket calculator. But if you were to take that same number, and without already knowing those two prime divisors, try to find its factors. You can see how much harder that is in reverse. That's part of how RSA cryptography works. Often the computer uses the system time and date to generate random seeds. Easy to do in the forward direction: Sit down at your PC at any time of day and load a new minecraft level. More time consuming in reverse: Set the exact time and day in which you created that level to attempt to create the same level again.
25th Dec 2021, 8:35 PM
DeAndre ReiChelle