1

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.

  • 2
    just use the built in random number generator of your language (python in this case). BTW< people have different interpretations of 'random' in regard to playlists. True random numbers will repeat songs. MOst peope really want 'random shuffle' - thats a different thing – pm100 Feb 27 '23 at 02:13
  • "because the RNG in every computer isn't really random". Oh, you know something I don't know about RDRAND instruction or `/dev/random`? Or the random number generators in Smart Cards, TPM's or HSMs? Those are more random than you may guess. We've moved on since the time of 8 bit computers in this respect as well. How do you expect that keys are generated on your computer? Do you understand that TLS - which secures your connection to this site depends on computer generated randoms as well? Have you looked [here](https://stackoverflow.com/q/20936993/589259)? – Maarten Bodewes Feb 27 '23 at 02:35
  • One test you can do for randomness is the "circle test": scale each random number to between 0 and 1, then take pairs a, b of them and check if sqrt((a * a) + (b * b)) < 1. The proportion of numbers < 1 (i.e. inside a circle of radius 1 centered on the origin) should closely approximate pi / 4 https://asecuritysite.com/encryption/mc Sorry to hear about your accident – samgak Feb 27 '23 at 02:42

0 Answers0