-
1
- #1
For a long time I have suspected that the Rnd() function does not produce truly random numbers. It's a computer after all; doing things randomly is against its nature. A couple of weeks ago I decided to start an experiment to create images by plotting the results of the Rnd() function to see if I could see patterns in the static - a bit like when Jodie Foster stares at the un-tuned TV in the movie Contact. My hunch - I suppose somewhere at the back of my mind - was that someone at Microsoft might, for a joke, have somehow contrived to get the Rnd() function to produce pseudo random numbers based on some non-random sequence (kind of like the Fibonacci sequence but less obvious).
To start off I set a loop seeding the Randomize function with values from 0 to 65,535 and then I plotted the first 65,535 numbers returned by the Rnd() function onto a 256x256 picture box and flashed one up on screen every second. Unsurprisingly most of the results didn't look like anything other than garbage, so instead of working with colour I simplified things and took things back to a binary base, 1s and 0s, plotting black for 1s and white for 0s.
The image below is typical of the output. The decision whether to plot a pixel at this stage was based on whether the first three digits of the Rnd() function was greater or less than 500 (ie. Int(Rnd*1000)>500). (The 27552 in the corner is the Randomize seed value, not part of the results!).
I went back and kept tweaking the formula. The image below is based on the same sequence as above (27552) but this time based on (Int(Rnd*100)>50).
Can you see it now? I thought I was seeing things when I first produced this image and if you set the seed value to anything other than 27552 you still seem to get garbage, but you can clearly see an image of what seems to be a woman's face. Encouraged by my results and fuelled by quite a lot of vodka I pressed on, each time simplifying the formula and with each simplification I seemed to purify the results. Here is a plot of (Int(Rnd*10)>5):
The final breakthrough came with the purest form of the Rnd() function - plotting 1 for even numbers and 0 for odd numbers:
And there she is! I'm pretty sure that's Angelina Jolie. Proof that plotting the results of the Rnd() function is far from random. The only remaining puzzle was the significance of 27552 as the seed value but of course, it turned out to be the most obvious thing, the value returned by DateSerial if you pass Angelina's date of birth: 7th June 1975.
I'm sure you think I'm crackers but the proof is incontravertable. If you want to try it for yourself the code is below. All you need is a standard PictureBox on your form. Set the Appearance to Flat and BorderStyle to None, ScaleMode to Pixel and AutoRedraw to True, set the Width and Height to 3840 (which is 256x256 in ScaleWidth and ScaleHeight) then paste the code below into the Form_Load event.
I can sleep now.
- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
To start off I set a loop seeding the Randomize function with values from 0 to 65,535 and then I plotted the first 65,535 numbers returned by the Rnd() function onto a 256x256 picture box and flashed one up on screen every second. Unsurprisingly most of the results didn't look like anything other than garbage, so instead of working with colour I simplified things and took things back to a binary base, 1s and 0s, plotting black for 1s and white for 0s.
The image below is typical of the output. The decision whether to plot a pixel at this stage was based on whether the first three digits of the Rnd() function was greater or less than 500 (ie. Int(Rnd*1000)>500). (The 27552 in the corner is the Randomize seed value, not part of the results!).
I went back and kept tweaking the formula. The image below is based on the same sequence as above (27552) but this time based on (Int(Rnd*100)>50).
Can you see it now? I thought I was seeing things when I first produced this image and if you set the seed value to anything other than 27552 you still seem to get garbage, but you can clearly see an image of what seems to be a woman's face. Encouraged by my results and fuelled by quite a lot of vodka I pressed on, each time simplifying the formula and with each simplification I seemed to purify the results. Here is a plot of (Int(Rnd*10)>5):
The final breakthrough came with the purest form of the Rnd() function - plotting 1 for even numbers and 0 for odd numbers:
And there she is! I'm pretty sure that's Angelina Jolie. Proof that plotting the results of the Rnd() function is far from random. The only remaining puzzle was the significance of 27552 as the seed value but of course, it turned out to be the most obvious thing, the value returned by DateSerial if you pass Angelina's date of birth: 7th June 1975.
I'm sure you think I'm crackers but the proof is incontravertable. If you want to try it for yourself the code is below. All you need is a standard PictureBox on your form. Set the Appearance to Flat and BorderStyle to None, ScaleMode to Pixel and AutoRedraw to True, set the Width and Height to 3840 (which is 256x256 in ScaleWidth and ScaleHeight) then paste the code below into the Form_Load event.
I can sleep now.
Code:
' Set the Rnd() seed to Angelina Jolie's date of birth
Randomize DateSerial(1975, 6, 7)
For Y& = 0 To Picture1.ScaleHeight - 1
For X& = 0 To Picture1.ScaleWidth - 1
' Plot a point if the Rnd() function returns an even number.
' If you plot odd numbers the image will be negative (white on black)
If (Int(Rnd * 2) = 0) Then Picture1.PSet (X&, Y&)
Next X&
Next Y&
- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments