Notices
General NON-Automotive Conversation No Political, Sexual or Religious topics please.

Computers - Are Random # Generators really random?

Thread Tools
 
Search this Thread
 
Old Aug 22, 2006 | 08:49 PM
  #1  
four-sixty-power's Avatar
four-sixty-power
Thread Starter
|
Fleet Mechanic
20 Year Member
Joined: Feb 2005
Posts: 1,782
Likes: 15
From: Lower Mainland B.C.
Computers - Are Random # Generators really random?

Computer programs have advanced a lot in the past 12 years. I took a computer course in highschool and we 20 students all input a program for a random number generator. We all got the same pattern of "random" numbers.

I was talking to a friend who works with computers for a living and he said it is quite involved as to how random numbers are generated but that basically it is based on the year/month/time setting of the computer.

Okay, but how?

Wouldn't the "pattern" be the same on the same day next year? or when the year/month/time number was added the same?

Can anyone explain it? (I believed him when he told me but I was tired and didn't retain it)
 
Reply
Old Aug 22, 2006 | 09:27 PM
  #2  
Mil1ion's Avatar
Mil1ion
New User
Joined: Jan 2008
Posts: 0
Likes: 24
Watching the show "Numb3rs" again Eh ?
 
Reply
Old Aug 22, 2006 | 09:44 PM
  #3  
four-sixty-power's Avatar
four-sixty-power
Thread Starter
|
Fleet Mechanic
20 Year Member
Joined: Feb 2005
Posts: 1,782
Likes: 15
From: Lower Mainland B.C.
I try not to watch Global(tm) programming
 
Reply
Old Aug 22, 2006 | 10:21 PM
  #4  
screwy's Avatar
screwy
Cargo Master
20 Year Member
Joined: Aug 2002
Posts: 2,117
Likes: 8
From: Over Yonder, MN
No they are not true random numbers, they are known as pseudorandom numbers. How they work is a little beyond me, but I do remember as a professor was trying to explain it he had mentioned that somewhere (MIT maybe?) they pointed photocells or something similar at lava lamps to help a computer generate true random numbers.
 
Reply
Old Aug 23, 2006 | 09:14 PM
  #5  
furball69's Avatar
furball69
Postmaster
Joined: Jul 2003
Posts: 2,628
Likes: 0
From: Calgary, Canada
I don't know how to explain how it works but in Visual Basic, you not only have to request your random number ("Rnd" command) that the program is to generate, but you have to insert the "Randomize" when the program loads.

This is what one of my books says about it: "The Randomize statment is added to the program and will be executed each time the program starts. Randomize uses the system clock to create a truly random starting point, or seed, for the Rnd statement used in the Command1_Click procedure."

Your friend probably confused 'system clock' with date, time etc.

If you double click your clock and actually watch it while your computer is busy, you'll probably notice that the seconds will lag behind once in a while, and then it will catch up, the 'system clock' is keeping track of all that.

What is the system clock?

In computers, sequence is everything. The system clock synchronizes the tasks in a computer, like loading data before manipulating it, etc. The system clock is a circuit that emits a continuous stream of precise high and low pulses that are all exactly the same length. One clock cycle is the time that passes from the start of one high pulse, until the start of the next. If several events are supposed to happen in one clock cycle, the cycle is subdivided by inserting a circuit with a known delay in it, thus providing more highs and more lows.
 

Last edited by furball69; Aug 23, 2006 at 09:28 PM.
Reply
Old Aug 23, 2006 | 09:26 PM
  #6  
Ford_Six's Avatar
Ford_Six
Hotshot
Joined: Oct 2002
Posts: 18,488
Likes: 22
From: The Big, Oregon
Club FTE Gold Member
There was some talk last year of using the cooling rates of resistors to generate random numbers, but I don't know what ever became of that. Generating a truly random number with a computer is pretty difficult, since everything in a computer is based off known values.
 
Reply
Old Aug 23, 2006 | 09:39 PM
  #7  
furball69's Avatar
furball69
Postmaster
Joined: Jul 2003
Posts: 2,628
Likes: 0
From: Calgary, Canada
I guess one thing that could be done is using a seed like how many miliseconds the computer has been turned on at the time the random call is made, and go from there using whatever calculations need to be made to get the desired type of number.
 
Reply
Old Sep 29, 2006 | 10:42 AM
  #8  
furball69's Avatar
furball69
Postmaster
Joined: Jul 2003
Posts: 2,628
Likes: 0
From: Calgary, Canada
To further add to my explanation, the fact that a computer program, that is written to pick a random number (without the 'randomize' statement), is meant to reproduce the same results by default. It is a feature of the programming language so that you can test the program while it is in development to see if your program is putting out expected results throughout the run of the program.

I think I read somewhere that some of the randomizers are based on the number of miliseconds since Ceasar's last breath - a number that will always be different.

On that note, I modified a practise program last night to generate random numbers and count how many times certain numbers came up. It's a computer slot machine that's been highly modified.

Check it out if you like.

http://members.shaw.ca/dvdguy/lucky70.jpg
http://members.shaw.ca/dvdguy/lucky7.jpg


http://members.shaw.ca/dvdguy/lucky7.html

I know the program works on my computer because I have the Development environment installed on it but there's a chance that there may be some missing DLL's or OCX's on other computers. Let me know which ones, if any so I can include them in the zip.

Standard disclaimer; there's no malware of any sort on the program and using the program is at your own risk.
 

Last edited by furball69; Sep 29, 2006 at 11:38 AM.
Reply
FTE Stories

Ford Trucks for Ford Truck Enthusiasts

story-0

10 Ways Ford is LOSING to the Competition

 Joe Kucinski
story-1

Top 6 Best Deals Available on New Fords & Lincolns Right Now

 Brett Foote
story-2

This Hennessey Takes the Expedition Tremor's Off-Roading Capability to the Next Level

 Verdad Gallardo
story-3

Top 10 Fords at 2026 Carlisle Ford Nationals

 Joe Kucinski
story-4

3 Best / 3 Worst Parts of Modern Ford Ownership

 Brett Foote
story-5

10 Amazing Upgrades That Solve Common Ford Truck Owner Headaches

 Pouria Savadkouei
story-6

Every 2026 Ford Engine Explained

 Brett Foote
story-7

10 Ugly Ford Trucks That We Still Kinda Love

 Joe Kucinski
story-8

10 Things Every Truck Owner NEEDS (2026 Edition)

 Michael S. Palmer
story-9

Rezvani's Latest Post-Apocalyptic Monster Is a Ford F-150 Raptor Underneath

 Verdad Gallardo
Old Sep 29, 2006 | 02:24 PM
  #9  
pitrow's Avatar
pitrow
Elder User
Joined: Mar 2005
Posts: 878
Likes: 0
From: Cornelius, Oregon
The simple way to think of it is each program has a huge set list of "random" numbers. This list is huge. When asked for a random number, you need to supply the computer a "seed", which is basically a starting point in that list. It grabs the random number from that location. The next time you ask for a random number it simply grabs the next number on the list, unless you "reseed" the random number function.

So by using the date and time and any other combination of changing numbers to create the seed, you get a random, non-reproducible set of numbers.

On the other hand, if you use the same seed everytime, you'll get the same set of "random" numbers everytime.
 
Reply
Old Sep 29, 2006 | 02:33 PM
  #10  
FTE Ken's Avatar
FTE Ken
Post Fiend
25 Year Member
Joined: Jan 1997
Posts: 23,165
Likes: 18
From: Enjoying the real world.
One thing I did many years ago with a program that required random numbers was to reseed the generator with the number of milliseconds between the keystrokes of the users. Its as close to random seeding as you can get on a PC without having to reference external sources.
 
Reply
Old Sep 29, 2006 | 02:39 PM
  #11  
furball69's Avatar
furball69
Postmaster
Joined: Jul 2003
Posts: 2,628
Likes: 0
From: Calgary, Canada
That would be useful for typing in the initial password for an encryption type program, such as PGP and the like.
 
Reply
Old Sep 29, 2006 | 10:50 PM
  #12  
furball69's Avatar
furball69
Postmaster
Joined: Jul 2003
Posts: 2,628
Likes: 0
From: Calgary, Canada
I thought I'd post the "meat and potatoes" of teh code that makes that program work, just for fun, so snyone interested in what a program looks like and what it does every time it cycles.

If RadioButton1.Checked = False Then
GoTo custom
End If
PictureBox1.Visible = False
Label1.Text = CStr(Int(Rnd() * 10))
Label2.Text = CStr(Int(Rnd() * 10))
Label3.Text = CStr(Int(Rnd() * 10))
If (Label1.Text = "7") Or (Label2.Text = "7") _
Or (Label3.Text = "7") Then
PictureBox1.Visible = True
Beep()
End If
GoTo done
custom:
Try
Label5.Text = "0"
Label6.Text = "0"
Label7.Text = "0"
Label8.Text = "0"
rolls1 = TextBox1.Text
If rolls1 < 0 Then
rolls1 = (rolls1 - rolls1 - rolls1)
End If
doubles1 = 0
triples1 = 0
singles1 = 0
nosevens = 0

Do Until rolls1 = 0

L1 = CStr(Int(Rnd() * 10))
L2 = CStr(Int(Rnd() * 10))
L3 = CStr(Int(Rnd() * 10))
If L1 <> 7 And L2 <> 7 And L3 <> 7 Then
nosevens = nosevens + 1
GoTo loopfin
End If
If L1 = 7 And L2 = 7 And L3 = 7 Then
triples1 = triples1 + 1
GoTo loopfin
End If
If L1 = 7 And L2 = 7 Or L1 = 7 And L3 = 7 Or L2 = 7 And L3 = 7 Then
doubles1 = doubles1 + 1
GoTo loopfin
End If
If L1 Or L2 Or L3 = 7 Then
singles1 = singles1 + 1
GoTo loopfin
End If
loopfin:
rolls1 = rolls1 - 1
Loop
Label1.Text = L1
Label2.Text = L2
Label3.Text = L3
TextBox1.Text = rolls1
Label5.Text = triples1
Label6.Text = doubles1
Label7.Text = singles1
Label8.Text = nosevens
Label9.Text = (triples1 + doubles1 + singles1 + nosevens)
Catch
MsgBo"Make sure you only enter numbers.", MsgBoxStyle.OKOnly, "Incorrect Input")
End Try
If (Label1.Text = "7") Or (Label2.Text = "7") Or (Label3.Text = "7") Then
PictureBox1.Visible = True
Beep()
End If
done:

End Sub
 
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
mantta
General NON-Automotive Conversation
8
Oct 30, 2008 10:35 AM
Mil1ion
General NON-Automotive Conversation
45
Sep 22, 2007 10:52 AM
packrat56
General NON-Automotive Conversation
15
Sep 19, 2007 10:57 AM
vancouverpower
General NON-Automotive Conversation
19
Jun 24, 2005 05:26 AM
thunderguns71
General NON-Automotive Conversation
18
Feb 26, 2005 11:43 AM




All times are GMT -5. The time now is 06:10 PM.

story-0
10 Ways Ford is LOSING to the Competition

Slideshow: 10 ways Ford is losing to the competition

By Joe Kucinski | 2026-06-15 09:52:01


VIEW MORE
story-1
Top 6 Best Deals Available on New Fords & Lincolns Right Now

Some great targets in today's expensive world.

By Brett Foote | 2026-06-15 09:35:19


VIEW MORE
story-2
This Hennessey Takes the Expedition Tremor's Off-Roading Capability to the Next Level

Slideshow: The VelociRaptor Expedition gains a lift, upgraded suspension, Brembo brakes, and trail-ready equipment while retaining the stock 440-horsepower EcoBoost V6.

By Verdad Gallardo | 2026-06-12 11:01:55


VIEW MORE
story-3
Top 10 Fords at 2026 Carlisle Ford Nationals

Slideshow: Top 10 Fords at 2026 Ford Nationals

By Joe Kucinski | 2026-06-09 11:10:08


VIEW MORE
story-4
3 Best / 3 Worst Parts of Modern Ford Ownership

Based on years of owning multiple modern Ford products.

By Brett Foote | 2026-06-09 10:53:36


VIEW MORE
story-5
10 Amazing Upgrades That Solve Common Ford Truck Owner Headaches

SPONSORED: From muddy boots to rain-soaked cargo, these upgrades address some of the most common frustrations Ford truck owners face every day.

By Pouria Savadkouei | 2026-06-08 18:50:34


VIEW MORE
story-6
Every 2026 Ford Engine Explained

Here's everything you need to know about every Ford engine available for the 2026 model year.

By Brett Foote | 2026-06-05 12:58:01


VIEW MORE
story-7
10 Ugly Ford Trucks That We Still Kinda Love

Slideshow: 10 ugly Ford trucks that we still kinda love.

By Joe Kucinski | 2026-06-03 09:51:16


VIEW MORE
story-8
10 Things Every Truck Owner NEEDS (2026 Edition)

Slideshow: the best gifts for dads & grads

By Michael S. Palmer | 2026-06-03 15:43:58


VIEW MORE
story-9
Rezvani's Latest Post-Apocalyptic Monster Is a Ford F-150 Raptor Underneath

Slideshow: Called the Fortress, the 850-horsepower pickup combines Raptor underpinnings with military-inspired features, survival equipment, and a starting price of $285,000.

By Verdad Gallardo | 2026-06-03 11:38:36


VIEW MORE