DEV Community

jawwad22
jawwad22

Posted on

How can you make computer generate a random number without using algorithm just like our brain do.

Top comments (5)

Collapse
 
harshitrathod profile image
Harshit rathod • Edited

First, There is no such thing as Random in our universe.

When you guess any random number there are so many hidden factors behind it. If someone suddenly stops me and ask for a random number, the answer can be my favorite number or amount of my last purchase or any value from time.
There are thousands of factors there which decide random number.

When your brain neurons try to find an answer from any knowledge base you have which will be systematic. and this pathfinding traversal within neurons will be different for all humans. Also, your knowledge base is changing with time so it is possible that I don't get similar information from the same place again.
Consider at some place X in your brain you have information about your last taxi number and when you give a random number, brain took it from place X.
After some time place X contain other information like your movie time so even we reach to X, we didn't get the same answer.

Considering all this thing I can say your question should look like
How can you make computer generate a random number using algorithm just like our brain do.

We can try to solve this by machine learning. Guess for a random number and create data sheet. Add some basic feature like time, your mood :)

WAALLA! you made computer to generate random number just like you.

Again, this is hypothetical and you required thousands of feature and data to predict.

Collapse
 
tobias_salzmann profile image
Tobias Salzmann

To my knowledge, there is true randomness in a lot of places where quantum mechanics are involved. Put a radioactive source in front of a geiger counter, and you got a sequence of events that are randomly spaced in time.

Collapse
 
itzikh profile image
itzik-h

Like one of these.
A good (expensive, military grade) TRNG will will use Radioactive decay which is a true random phenomena.

Collapse
 
maruru profile image
Marco Alka

There are different types of randomness to random numbers. Usually, we differentiate between pseudo random numbers and true random numbers. Pseudo random numbers are generated by using an algorithm, which takes many factors into one formula to come up with a number.

You could use the current time in ns, the current CPU frequency, the current GPU temperature, the uptime, a HID, etc. and put them as seed into an algorithm like the Mersenne Twister to receive a random number. The downside is, that given the same environment, one can re-calculate the random number. Since it is re-calculable, it only can be used for low-security applications (for example randomness in computer games).

True random numbers usually can be used for cryptography, hence are very interesting for a wide number of applications, like secure banking transactions, transmission of secrets (e.g. military).

In order to create a true random number, one usually takes a constantly, rapidly changing outside phenomenon translates it into a number, and inserts it into a formula. Such an outside phenomenon can be radio waves, radiation, atmospheric noise, chaotic lasers, etc. They usually require additional hardware sensors, however generate a number, which is hard (ideally impossible) to reconstruct, guess or intercept in any way.


Summary: In order to easily get a low-quality random number, you can use something like the current ns, slice them like a string and only take the last few digits. In order to get a medium quality random number, you might want to take a number from /dev/random, which includes pre-calculated random numbers with a "good" algorithm. For high-quality random numbers, you will need extra hardware, which provides a value from a physical phenomenon, which cannot be reconstructed.

Collapse
 
msoedov profile image
Alex Miasoiedov

Our brains can't do a good job generating random numbers. The random numbers generated from a human brain does not simply form a good Gausian distribution (see Central limit theorem). IRS usually use this to detect made up numbers in tax reports.