+ 5

How actually random numbers generated?

NOT ANY SPECIFIC LANGUAGE RELATED We know machine can't do anything its own then how randomly numbers are generated? đŸ€”

14th Mar 2021, 7:46 AM
Deepesh Patel
Deepesh Patel - avatar
11 Respostas
+ 6
All random number generators only generate pseudo-random numbers. It means that they are not truly random Eg: Random numbers generating methods like randint() in python works using algorithms to generate random numbers, they aren't truly random These might be helpful: https://www.sololearn.com/discuss/2024995/?ref=app https://www.sololearn.com/discuss/1770772/?ref=app https://www.sololearn.com/discuss/1318339/?ref=app
14th Mar 2021, 7:57 AM
A C K
A C K - avatar
+ 6
I think this article will help you How Computers Generate Random Numbers" https://www.howtogeek.com/183051/htg-explains-how-computers-generate-random-numbers/amp/
14th Mar 2021, 8:00 AM
!Derrickee
!Derrickee - avatar
+ 6
To supplement <Derrickee/>'s answer: Let's take a "random number generator" that works like x -> x + 1 Starting from 1 and applying the formula over and over it generates the sequence 1, 2, 3, 4, 5, ... not very random at all. Let's instead use the formula x -> (x + 133) * 7 % 13 it generates 1, 2, 9, 6, 11, 7, 5, 4, 10, 0, 8, ... which already looks a lot better. Finding formulae that produce very random looking patterns is the job of statisticians and it's pretty hard. A lot of study and design goes into finding good PRNGs. For example a good PRNG should hit each number equally often and we also want to produce number streams that don't have any hidden patterns in them, so, like truly random numbers. Things like that. (The PRNG in my example is horrible just to be clear. It repeats on every 12th number and doesn't generate 3, ever.)
14th Mar 2021, 10:07 AM
Schindlabua
Schindlabua - avatar
+ 3
Natural random bits can be generated using a naturally random process such as radioactive decay.
15th Mar 2021, 4:45 AM
Sonic
Sonic - avatar
+ 3
Random numbers are made virtually by using various algorithms that generate seemingly random numbers. Suppose the one given by Schindlabua: (x+133)*7%13. Now, how is 'x' calculated here? The variable the algorithm takes in is called the 'seed' value and usually, it's the system time (random enough for a game of Ludo). P.S. Something internally is done to continue this process once a seed value is fed. Consider this: import random random.seed(4) for x in "...": print(random.random()) """ Here, the next "variable" is decided by the previous state. That's why, it generates the same sequence if the seed is repeated, as the initial result yields the same everytime. Note that a just a very small difference in the seed values specified, say a difference of 0.0000000000001, significantly changes the output. In case I've typed anything wrong, please let me know. """
16th Mar 2021, 2:09 AM
Calvin Thomas
Calvin Thomas - avatar
+ 3
Aria 😇Well done for reading. I have not actually read itđŸ€Ș
16th Mar 2021, 5:13 AM
!Derrickee
!Derrickee - avatar
+ 2
If a computer or algorithm is used to generate a sequence of numbers it won't be random.
15th Mar 2021, 4:40 AM
Sonic
Sonic - avatar
+ 2
<Derrickee/> Wow that article is very interesting, especially the part about truly random numbers. It is very interesting to think about what other things could be used to generate truly random numbers.
16th Mar 2021, 4:30 AM
Aria
Aria - avatar
+ 1
Most 4G languages have a custom function like RND.
16th Mar 2021, 3:11 AM
Sanjay Kamath
Sanjay Kamath - avatar
0
Random numbers are generated by using time of computer because you time will never stop ticking.
14th Mar 2021, 9:26 AM
🌀 Shail Murtaza ŰŽŰčیل Ù…Ű±ŰȘŰ¶ÛŒÙ°
🌀 Shail Murtaza ŰŽŰčیل Ù…Ű±ŰȘŰ¶ÛŒÙ° - avatar
0
We can create the random numbers using many functions and language but they are not really random. But if we add one thing into that function then it becomes truly random that the current time as the parameter. For ex: rand() This code generate the random number in c++ but every time it generate same number pattern But rand(time(0)) generate truly random number because it takes the current time as parameter which changes every second so it becomes truly random.. Hope you got your answer.
14th Mar 2021, 4:27 PM
Illa Bahadur Darlami Magar
Illa Bahadur Darlami Magar - avatar