Author Topic: Question for old time computer programers:  (Read 470 times)

Offline eskimo2

  • Platinum Member
  • ******
  • Posts: 7207
      • hallbuzz.com
Question for old time computer programers:
« on: February 02, 2003, 08:36:09 AM »
How do programs produce random numbers?

I was playing solitare on the computer for the first time ever yesterday.  Thinking about the avility to random shuffle gave me a flashback to high school computer class in 1983...  We were writing simple graphic programs and I remember messing around with the computers ability to pick a random number out of any set of numbers.

As I look back on this, it seems to me now that that must be a very unnatural thing for a computer to do... to choose something without a pattern, cause, or reason.  Computers work on logic and math.  How do you use logic and math to create a whim?

So what is the math theory behind having a computer pick a random number?

Thanks,

eskimo

Offline ra

  • Parolee
  • Gold Member
  • *****
  • Posts: 3569
Question for old time computer programers:
« Reply #1 on: February 02, 2003, 09:18:03 AM »
There is no easy answer, but you are right, it is doubtful that a computer program can produce truly random numbers.  I've heard that there is a kind of hardware which contains a radioactive isotope.  The hardware detects the radioactive decay and somehow converts the information into a continuous stream of digits, which is then used by a computer for random numbers.

ra

Offline Swoop

  • Plutonium Member
  • *******
  • Posts: 9180
Question for old time computer programers:
« Reply #2 on: February 02, 2003, 09:19:47 AM »
Algorithm using cpu clock as a random number seed.


Offline bounder

  • Nickel Member
  • ***
  • Posts: 720
      • http://www.332viking.com
Question for old time computer programers:
« Reply #3 on: February 02, 2003, 09:24:13 AM »
There is a site on the web that uses a CCD and a lava lamp to generate random numbers for use in computers, but whether they are truly random is doubtful.

Otherwise computers tend to use lists of pregenerated number I think.

Offline eskimo2

  • Platinum Member
  • ******
  • Posts: 7207
      • hallbuzz.com
Question for old time computer programers:
« Reply #4 on: February 02, 2003, 09:41:10 AM »
Quote
Originally posted by bounder
There is a site on the web that uses a CCD and a lava lamp to generate random numbers for use in computers, but whether they are truly random is doubtful.

Otherwise computers tend to use lists of pregenerated number I think.


So if you had 2 identical PCs, with the same OS, and the same card game, all brand new - each had never run the random program yet, they would deal the same cards on the same game when run for the first time?

eskimo

Offline the_hegemon

  • Copper Member
  • **
  • Posts: 143
      • http://127.0.0.1
Question for old time computer programers:
« Reply #5 on: February 02, 2003, 10:41:17 AM »
Quote
Originally posted by bounder
Otherwise computers tend to use lists of pregenerated number I think.



Computers tend to use functions seeded with the CPU clock or some other information that changes frequently, as Swoop stated.  However, the results are only pseudo-random, and not truly random.


darkstar

Offline eskimo2

  • Platinum Member
  • ******
  • Posts: 7207
      • hallbuzz.com
Question for old time computer programers:
« Reply #6 on: February 02, 2003, 11:08:53 AM »
Quote
Originally posted by the_hegemon
Computers tend to use functions seeded with the CPU clock or some other information that changes frequently, as Swoop stated.  However, the results are only pseudo-random, and not truly random.


darkstar


Can you explain further?

eskimo

Offline Skuzzy

  • Support Member
  • Administrator
  • *****
  • Posts: 31462
      • HiTech Creations Home Page
Question for old time computer programers:
« Reply #7 on: February 02, 2003, 11:54:30 AM »
The numbers are not random actually.  If you run long enough a pattern will emerge.

And yes,..if you took two computers, and seeded the random number generator (most modern computers have hardware that does this) with the same value, the pattern of numbers would match.

In a computer, random numbers never occur.  The idea behind the random number is to produce a set of numbers which appear to have no pattern to a person.
Roy "Skuzzy" Neese
support@hitechcreations.com

Offline hardcase2

  • Zinc Member
  • *
  • Posts: 43
Question for old time computer programers:
« Reply #8 on: February 02, 2003, 12:25:54 PM »
and old method for rolling dice was a number generator that created a number from .00000001 to .99999999 and then multiplying that number by 6 then rounding up or down to the interger.

Offline AKIron

  • Plutonium Member
  • *******
  • Posts: 12643
Question for old time computer programers:
« Reply #9 on: February 02, 2003, 12:44:08 PM »
Is this the beginning of another "free will" debate? ;)
Here we put salt on Margaritas, not sidewalks.

Offline Arlo

  • Radioactive Member
  • *******
  • Posts: 24759
Question for old time computer programers:
« Reply #10 on: February 02, 2003, 12:52:20 PM »
Doesn't appear to be.

Offline AKIron

  • Plutonium Member
  • *******
  • Posts: 12643
Question for old time computer programers:
« Reply #11 on: February 02, 2003, 01:11:06 PM »
hehe, was joking.

Like Suzzy suggested, it's just matter of perspective.
Here we put salt on Margaritas, not sidewalks.

Offline john9001

  • Plutonium Member
  • *******
  • Posts: 9453
Question for old time computer programers:
« Reply #12 on: February 02, 2003, 01:58:22 PM »
Quote
Originally posted by Swoop
Algorithm using cpu clock as a random number seed.



swoop is right , at least as far as BASIC programs go, i used to write programs to generate ramdom lotto numbers.

the "randomness" occures when i would hit a key, the random sub-program would not grab the CPU clock until it got the "keypress"

BASIC  had a command for the ramdom function , but you had to write the programing to set the parimiters for the numbers you wanted , IE: seven different numbers & print,  etc

44MAG

"ramdom?? , god, i spell worse than HT
« Last Edit: February 02, 2003, 02:05:39 PM by john9001 »

Offline Tuomio

  • Nickel Member
  • ***
  • Posts: 523
Question for old time computer programers:
« Reply #13 on: February 02, 2003, 04:07:52 PM »
For my understanding, only random thing in the world is decaying of atom. Google for Schrodingers Cat, its simple "theory" of this process, even i can understand it..=)

Computers random is, like Skuzzy said, an algorithm, that picks one of its variables from computer clock. The randomness follows a bezier curve, but isnt apparent if your sampling rate isnt exactly evenly spaced. Ie enter press per every second hardly is exact enough to bring up this pheomenon..:) God knows how many different states a computer clock can have in one second, but i think its somehow related to the MHZ of your CPU.

I have only faint memory of this issue in my mind and i might be totally off the base here. So, forget what i said and do a websearch..:D

Offline AKIron

  • Plutonium Member
  • *******
  • Posts: 12643
Question for old time computer programers:
« Reply #14 on: February 02, 2003, 06:31:44 PM »
Being in the computer and network support business I've seen folks prove that PCs are capable of randomness. At least that's how it seems when they want me to find that file they just saved. ;)
Here we put salt on Margaritas, not sidewalks.