I have been thinking about random numbers a lot. I am looking for different ways of generating random numbers because the RNG in every computer isn't really random. I notice this mostly with music players. Whenever I play my music on random, it always repeats certain songs and skips others all together. Each time I reset my music player, different songs get repeated, but the pattern remains the same; certain songs get pick way more often then others.
So I thought about how to generate more "naturally" random numbers. Where does "true" randomness exist in a computer? The answer I came up with is in the cpu. The cpu clock will tick at different rates every picosecond because of a multitude of factors: Load, temperature, power fluctuation, etc. I concluded that taking snapshots of the clock at regular intervals would yield random numbers deep in the decimal ranges, from 100 microseconds - 1 picosecond (0.00000n - 0.00000000n)
I wrote the following script to test this..
#!/usr/bin/env python
import time
ct = 0
#Are these numbers random?
while ct < 10:
print (str(time.monotonic())[-4:-1],str(time.monotonic())[-4:-1],str(time.monotonic())[-4:-1],end='\n')
ct += 1
Output:
710 062 469
345 863 084
639 060 263
643 057 258
627 039 249
032 767 971
436 839 040
637 097 302
693 158 937
175 207 402
So now I ask those who know, are these numbers random?
Sorry for the lack of technical know-how.. I used to be a mechanic but I lost an arm in a motorcycle accident. Now I'm teaching myself what I can in computer science. Random numbers and prime numbers interest me, but I obviously don't know much about either.
Aucun commentaire:
Enregistrer un commentaire