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

Ford's 2001 Explorer Sportsman Concept Looks For a New Home

 Verdad Gallardo
story-1

10 Best Ford Truck Engines We Miss the Most!

 Joe Kucinski
story-2

2026 Shelby F-150 Off-Road: Better Than a Raptor R?

 Brett Foote
story-3

2027 Super Duty Carhartt Package First Look: 12 Things You NEED to Know!

 Michael S. Palmer
story-4

10 Most Surprising 2026 Ford Truck Features!

 Joe Kucinski
story-5

Top 10 Ford Trucks Coming to Mecum Indy 2026

 Brett Foote
story-6

5 Best / 5 Worst Ford Truck Wheels of All Time

 Joe Kucinski
story-7

Ford Super Duty: 5 Things Owners LOVE, 5 Things They LOATHE!

 Joe Kucinski
story-8

Every 2026 Ford Truck Engine RANKED from WORST to FIRST!

 Michael S. Palmer
story-9

The Best F-150 Deal of Every Trim Level (XL through Raptor)

 Joe Kucinski
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 01:53 AM.

story-0
Ford's 2001 Explorer Sportsman Concept Looks For a New Home

Slideshow: Ford's bizarre fishing-themed Explorer concept has resurfaced after spending decades largely forgotten.

By Verdad Gallardo | 2026-05-12 18:07:46


VIEW MORE
story-1
10 Best Ford Truck Engines We Miss the Most!

Slideshow: The 10 best Ford truck engines we miss the most.

By Joe Kucinski | 2026-05-12 13:09:47


VIEW MORE
story-2
2026 Shelby F-150 Off-Road: Better Than a Raptor R?

Slideshow: first look at the 810 hp 2026 Shelby F-150 Off-Road!

By Brett Foote | 2026-05-12 12:50:07


VIEW MORE
story-3
2027 Super Duty Carhartt Package First Look: 12 Things You NEED to Know!

Slideshow: Everything You Need to Know about the 2027 Super Duty Carhartt Package!

By Michael S. Palmer | 2026-05-07 17:51:06


VIEW MORE
story-4
10 Most Surprising 2026 Ford Truck Features!

Slideshow: 10 most surprising Ford truck options/features in 2026.

By Joe Kucinski | 2026-05-05 11:17:22


VIEW MORE
story-5
Top 10 Ford Trucks Coming to Mecum Indy 2026

Slideshow: Here are the top 10 Fords coming to Mecum Indy 2026.

By Brett Foote | 2026-05-04 13:49:49


VIEW MORE
story-6
5 Best / 5 Worst Ford Truck Wheels of All Time

Slideshow: The 5 best and 5 worst Ford truck wheels of all time

By Joe Kucinski | 2026-04-29 16:49:01


VIEW MORE
story-7
Ford Super Duty: 5 Things Owners LOVE, 5 Things They LOATHE!

Slideshow: Ranking the 5 things owners love about their Super Duty and 5 things they don't

By Joe Kucinski | 2026-04-29 16:36:49


VIEW MORE
story-8
Every 2026 Ford Truck Engine RANKED from WORST to FIRST!

Slideshow: Ranking all 12 Ford truck engines available in 2026.

By Michael S. Palmer | 2026-04-22 13:32:20


VIEW MORE
story-9
The Best F-150 Deal of Every Trim Level (XL through Raptor)

Slideshow: The best Ford F-150 deal for every trim level (XL through Raptor)

By Joe Kucinski | 2026-04-21 15:59:01


VIEW MORE