I've run a test on your code, based on a test the I did (some time back) for the
I've incorporated your code (that you posted at the beginning of this thread) in a function that I've named
In order to get some 'density', with my app, it was necessary to have an iteration count up at 10.000.000, which means that the process takes about 30 minutes to run. By contrast, using the
The point here is that if one can see a 'pattern', then the results are not random, but if the window is filled with what looks like 'noise', then there is some semblance of 'randomness'.
I've posted a screen grab here, so that you (or anyone else) does not have to wait around for a half hour, to see the results, but, of course, one can choose to do that. Simply running this, with the first set of
As you can see, from the screen grab, there is a pattern, which (to my mind) suggests that this is far from a random number generator.
Is this a valid test, or is it flawed?
random.randint()
function.I've incorporated your code (that you posted at the beginning of this thread) in a function that I've named
prng()
and clearly marked the code that you posted, and commented the changes needed in order to have it work with my app. In order to get some 'density', with my app, it was necessary to have an iteration count up at 10.000.000, which means that the process takes about 30 minutes to run. By contrast, using the
random.randint()
function as is (that is to say, with a zero to 800 range), an iteration count of 100.000 is as high as you need, because if you go much higher than that, the 800 x 600 window would be completely filled and as such, no pattern would be seen.The point here is that if one can see a 'pattern', then the results are not random, but if the window is filled with what looks like 'noise', then there is some semblance of 'randomness'.
I've posted a screen grab here, so that you (or anyone else) does not have to wait around for a half hour, to see the results, but, of course, one can choose to do that. Simply running this, with the first set of
r1
and r2
takes, seconds, with the iteration count set to 100000
.As you can see, from the screen grab, there is a pattern, which (to my mind) suggests that this is far from a random number generator.
Is this a valid test, or is it flawed?
import random import tkinter as tk from tkinter import Canvas #=======<WT550 CODE START>======# import time number_of_needed_numbers = 10000 lower_value = 0 upper_value = 800 # I've changed this from 1 to 800, so that it fits this app short_time = 0.00000000000001 OFFSET_TIME = 0.03258312993051001 def prng(): start_time = time.time() start_time2 = start_time - OFFSET_TIME time.sleep(short_time) end_time = time.time() total_seed = end_time - start_time2 random.seed(total_seed) random_number = random.randint(lower_value, upper_value) return random_number #======<WT550 CODE STOP>=======# root = tk.Tk() # creat the root window root.geometry("800x600") root.title("Random Plot") root.resizable(False, False) C = Canvas(root, bg="#BABDB6", height=600, width=800) for p in range (100000): # change this to > 1000000 to use the prng() function. # use this with a iteration of apx 100000 r1=random.randint(0,800) r2=random.randint(0,800) # ... or this with a iteration of 10000000 to reproduce what I've posted here #r1 = prng() #r2 = prng() r3=r1+1 r4=r2+1 p = C.create_rectangle(r1,r2,r3,r4, fill='black') C.grid() root.mainloop()
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein