Donate SIGN UP

artificial intelligence?

Avatar Image
claymore | 06:35 Mon 08th Dec 2008 | Science
15 Answers
If you wrote a program for a computer which contained all the numbers from 1to 100 and instructed it to pick a random number , would it be able to, and if it did how did it decide which one to pick?

Answers

1 to 15 of 15rss feed

Best Answer

No best answer has yet been selected by claymore. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
A truely random number is difficult, if not impossible to generate.

Computers are deterministic so with the same input with the same timings you'd get the same result.

There are common peudo random number generation routines. ( wikipedia page here: http://en.wikipedia.org/wiki/Random_number_gen erator )

It rather depends on exactly how random it needs to be. The system could just take the last 2 digits of the system clock in microseconds when you press enter which would be good enough for most applications.
-- answer removed --
Oh gosh no Zac.

If you want a computer to generate a truely random number it's dead easy but you need to add just a tiny amount of hardware.

It would be the easiest thing in the world to construct a board with a small detector and radioactive source like you have in smoke detectors.

Plug it in and generate true random numbers.

It's just that most applications don't need that degree of randomness
Computers generally generate what are known as psuedo random numbers and that is done using a routine designed to produce what is ostensibly a random number using non random means, ie some sort of algorithm and calculation takes place. A common method is to use the internal clock that would usually tick in microseconds. A programmng language would have some sort of function eg RND(X, Y) so coding N=RND(1,100) would generate a random bumber bewtween 1 and 100. The actual calculation could be a simple matter of taking the last 3 digits of the clock and texting if it is in range and looping around until it is.
This is of course nothing to do with intelligence artificial or otherwise. The machine is obeying instructions.
There's an echo in here!
As mentioned above its just a pseudo random generator. I believe the problem is that after generating a set squence of numbers the whole thing repeats itself with the same sequence so is not really random at all.
Question Author
thanks everyone but I think you are missing the point a bit . at the pub where I work there is computer generated horse racing which you can bet on and win big money. It is a program which has 1000 races, 12 horses in each race. After 1000 races it starts at no1 again . The computer picks 1st 2nd and 3rd in each race. In race no 100, the numbers 4,9,1 came up,the next time race no 100 came up the nos were 3,1,4. I asked some whizz kid about this and he said the winning nos are not programmed in, the computer randomly picks them. just wondering how.
I thought I explained how, it would probably use a calculation based on the internal clock. eg you want a number between 1 and 12, here are the psuedo instructions for a typical random number function.

1 Read the last 2 digits of the internal clock (microseconds)
2. Is the number Greater than 0 and less than 13?
3 if yes return number to the program, end
4. Go to 1

That would generate 1 random number, repeat for as many as you need with checking to make sure you don't get 2 of the same (for this application of course)

Get it? a very simple algorithm.
Obviously you where under the impression that race N would always be the same result! The people that program these things will have thought of any bar room ruse mate!

In fact I'm surprised it has "1000 races" this is purely arbitrary as the number of races is infinite, it's just picking 3 random numbers from 1 to 12 continually. Although the number of different outcomes is finite, ie perm any 3 from 12.
R I Geezer, please (or anyone!). What is the number of permutations of any 3 from 12 ? What's the formula?
To Fredpuli:

In general the number of permutations is denoted by P(n, r), or nPr, where:

n is the number of elements available for selection, and
r is the number of elements to be selected (0 ≤ r ≤ n).

The general case is given by the formula:

P(n,r)= n!/(n-r)!

The ! rperesents 'factorial'- eg 3!= 3x 2x1

In your case it's P(12,3) =12!/(12-3)! = 12 x 11x 10 = 1320
The P(n,r) formula assumes the order is important. If the order isn't important we need to calculate C(n,r) instead.

C(12,3)= 12!/(9!x 3!)=220
yes what factor said! in this case there are 1320 possible outcomes.

Claymore, do you understand now?
-- answer removed --

1 to 15 of 15rss feed