* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download // DOES RANDOM MEAN PURE CHANCE? It is hard to know if
Survey
Document related concepts
Transcript
// DOES RANDOM MEAN PURE CHANCE? It is hard to know if randomness is well understood, even by those of us who are supposed to know the difference. It is all about language and how it is used. Words get used imprecisely and their meaning is often not well understood — just think of mathematicians saying: “the rational numbers, although infinite, are countable, while the irrational numbers, also infinite, are uncountable”, etc., ad nauseam. So often are words used to differentiate the subtlety between concepts that many of us are perplexed when common words are used in a very demanding and precise field such as mathematics. Many years ago when I was a graduate student at Rutgers University in New Brunswick, New Jersey, a fellow graduate student mentioned in passing that random meant “equally likely.” She emphatically went on to say that is all it is — nothing more! Well, more precisely, randomness must mean something more. Police: Victims shot by high-power rifle at random Five shot dead in Washington suburbs http://www.cnn.com/2002/US/South/10/04/maryland.shootings/index.html From Fran Lewine (CNN) Friday, October 4, 2002 Posted: 1:04 PM EDT (1704 GMT) The news article cited above is an example of how we associate randomness to a tragic story about five people being shot to death, apparently at random, in an exclusive suburb of Washington, DC. All incidents were relatively close in time and location. The word random is used several times in the CNN article, but were the shootings random? In a mathematical sense, there’s a choice being made here — specifically whom to shoot. Apparently, the victims do not know their killer, but the killer clearly chooses his victim — the killer is using a high-power rifle and is taking aim. So, how does the killer choose his victims? Possibly, when the conditions are right, the killer takes aim and just shoots. Many factors are at play here: certainly, the killer’s comfort is paramount in the process. A careful analysis of these events would probably lead one to believe that not all people are equally likely. The choice is not random, but our ability to predict who will be the next victim is highly uncertain. Maybe that’s what we mean by the word random. A purely random version of this event does not require that all people are equally likely to be shot, just that given exactly the same conditions, the likelihood of anyone being shot is equal. It is just simple intuition that allows people to avoid the killer’s bullet, maybe something as simple as staying home or avoiding places that are determined optimal for this killer’s comfort and line-of-sight. A truly random way to select victims would be to assign every person on earth at time t a number, then toss these numbers into a very big bin, mix well and then select one of these numbers to be the victim. In such a death by number situation, every person is on equal footing and has an equal chance of being picked. So let’s say that this is what † PAGE 14 DETERMINISTIC UNCERTAINTIES we mean by random: given any set S , the likelihood of picking one element from the set S is as probable as picking any other element from the set S . By the way, if someone’s picking numbers, we still have no idea what the next number will be. † Furthermore, truly random events need to independent of the past — we may know † something will happen (a number will be picked), but we cannot say with † certainty what that number will be even if we know the past. In mathematics, we often talk of a random variable X . For the type of problem we have been discussing so far, the random variable might be locations in space and time that can be assigned a probability of a shooting occurring there and then. Truly random variables like these are very complicated indeed. It is best to † look at a simpler case first, but first a somewhat mathematical definition is needed of what a random variable is. Let X denote a random variable, such that X Œ (-•, •) where X is mapped to a real number y Œ [0, 1] . Not to confuse matters here, but X need not be a single number and in fact can be an interval. The corresponding probability mass function is denoted by p X ( x† ) , which assigns a probability, y Œ [0, †1] , to each element in†the set † fact — both X , X Œ (-•, •) . The†set X can in fact be quite large — infinite in countable and uncountable, both discrete and continuous. This concept alone could be † † an entire course in itself. † † † The probability that the random variable X takes on a single value x is denoted by P{ X = x} (which is a single value) or P{ xl < X < xu } (which is an interval ( xl , xu ) , both countable and uncountable). All probabilities must be greater than or equal to zero † † and the sum of probabilities of all mutually exclusive events must be one. † † † Suppose we have a very simple random variable X that can only take on the values: 0 , 1, 2 , and 3 for example. You can think of this as a very simple card game consisting of fourteen cards: two ‘ 0 ’ cards, five ‘ 1’ cards, three ‘ 2 ’ cards, and four ‘ 3’ cards. † Here is the mathematical notation that explicitly lists these four events and their † † probabilities. † corresponding † † † † 2 ; 14 5 p X (1) = P{ X = 1} = ; 14 3 p X (2) = P† { X = 2} = ; 14 p X (0) = P{ X = 0} = † † † PAGE 15 p X ( 3) = P{ X = 3} = DETERMINISTIC UNCERTAINTIES 4 . 14 X is a random variable, but the events are not equally likely. Possibly, we prefer a scenario with†equally likely outcomes. For example: suppose we have a random variable Y that can only take on the values: 0 , 1, 2 , 3 to illustrate. You can think of † simple collection of one-hundred colored balls: twenty-five red balls, this as a very twenty-five green balls, twenty-five blue balls, and twenty-five white balls. Here we † † † † † have: 25 ; The numerical value of 0 indicates a red colored ball. 100 25 ; The numerical value of 1 indicates a green colored ball. pY (1) = P{Y = 1} = 100 † 25 ; The numerical value of 2 indicates a blue colored ball. pY (2) = P{Y = 2} = 100 † 25 ; The numerical value of 3 indicates a white colored ball. pY ( 3) = P{Y = 3} = 100 † pY (0) = P{Y = 0} = † † † † Y is a random variable, but this time each of the four outcomes†are equally likely. A physical event that we often associate with randomness is the toss of a fair die, where the † possible outcomes are 1, 2 , 3, 4 , 5 , and 6 . Being fair means that any face is as likely to come up as any other face, so if we let the random variable be D , we have: † † † † † † pD ( D = d Œ {1, 2, 3, 4, 5, 6}) = 1 6 † Again, what we need to know is that the probability that the random variable D takes on the value †d is denoted by P{ D = d} (which is a single value) or P{dl < D < d u } (which is an interval (dl , d u ) ). All probabilities must be greater than or equal to zero † and less than or equal to one and the sum of probabilities of all mutually exclusive † † events must be one. † † One random variable in particular that will interest us is the uniform random variable. This is a continuous function on an interval [a1 , a2 ] and is uniform (constant) on the interval. The function here is: † PAGE 16 DETERMINISTIC UNCERTAINTIES Ï 1 Ô f ( x) = Ì a2 - a1 ÔÓ 0 if a1 £ x £ a2 otherwise If xl Œ [a1 , a2 ] < xu Œ [a1 , a2 ] then † x † † Ûu 1 x -x P{ xl < X < xu } = Ù dx = u l . ıxl a2 - a1 a2 - a1 Actually, most computers can generate a pseudo-random integer from 0 to n with the following distribution: pU (u ) = P{U = u} = 1 for "u Œ [0, n] . n +1 † † Even though the computer is anything but random — that is why we use the term † — we are going to call †these numbers random from here on out. pseudo-random Furthermore, computers are discrete and cannot accurately model continuous events, so we should further state that continuous is really pseudo-continuous when dealing with computers. Here the n represents some maximum random integer that is machine specific. This discrete random variable can be used to generate other well know random variables, including the continuous uniform random variable, and we will spend most of our time † using this discrete random variable U . First let’s look at how C++ deals with random numbers. Specifically what is the n or † computer system? Run the following the maximum random integer for our particular code on your computer: † #include <iostream> // needed for cout #include <cstdlib> // needed for RAND_MAX using namespace std; int main () { cout << RAND_MAX << endl; } // main function A Macintosh G4 running Mac OS X gives 2,147, 483, 647 = (2 31 -1) as the maximum † PAGE 17 DETERMINISTIC UNCERTAINTIES random integer. That is a big integer by anyone’s standards. Even if you could count that high, it would take more than a lifetime to get there. For now, let us trust our computers to generate the following distribution: P{U = u Œ [0, 2,147, 483, 647]} = 1 2,147, 483, 648 The function that we need to call to get one of these i Œ [0, 2,147, 483, 647] , is † code to get ten random integers. rand(). Run this #include <iostream> // needed for cout #include <cstdlib> // needed for rand() and RAND_MAX using namespace std; † int main () { int n; for ( n = 1 ; n <= 10 ; n++) cout << rand() << endl; } // main function Your output will vary, but you should expect to see ten integers in all. Here’s one possible output: 1,103,527,590; 377,401,575; 662,824,084; 1,147,902,781; 2,035,015,474; 368,800,899; 1,508,029,952; 486,256,185; 1,062,517,886; and 267,834,847 Unbelievably, there are more than 5.7 ¥ 10 86 other groups of ten. If we were to call rand() ten million times, how many of these calls would be less † † , would we expect to see any † rand() than 1, 000 ? That is, of ten million calls to numbers less than 1, 000 ? Well there are 2,147, 483, 648 possible numbers rand() could return, and we are looking for the event where rand() returns 0 , 1, 2 , … , 999 . † The big assumption, once again, is that all u Œ [0, 2,147, 483, 647] are equally likely, † † with probability: † † † P{U = u Œ [0, 2,147, 483, 647]} = 1 †. 2,147, 483, 648 The other assumption is that each call to rand() is independent of any prior calls to † rand(). Assumptions like these can be very dangerous, but more on that later. Run the following program to see what happens. † PAGE 18 DETERMINISTIC UNCERTAINTIES #include <iostream> // needed for cout #include <cstdlib> // needed for rand() and RAND_MAX using namespace std; int main () { int n; int success = 0; for ( n = 1 ; n <= 10000000 ; n++) if (rand() < 1000) success++; cout << success << " successes out of a 10,000,000 calls to rand().\n"; } // main function One run of the program produced four successes. Your results may vary. The important thing here is getting a feel for how large the set of random integers is, and how small the probability is of getting any one integer — even an interval containing 1, 000 integers is unlikely. Given ten-million random integers, I only got four successes, that is a 0.00004% success rate — so it’s not very likely to see rand() returning numbers below 1, 000 . Actually, any group of this size, regardless of what interval is specified has a very small chance of occurring. Again, what is most important is to get a feel for the size of this†discrete set. It is enormous! † Most people would rather shrink the range to a more manageable size. Here is one possible mapping, which takes a random integer from [0, 2,147, 483, 647] and maps it to a floating-point number: 0 = 0; 2,147, 483, 647 1 1Æ ; 2,147, 483, 647 2 2Æ † ; 2,147, 483, 647 3 3Æ † ; 2,147, 483, 647 † 0Æ M † i iÆ ; 2,147,†483, 647 M † 2,147, 483, 647 2,147, 483, 647 Æ =1 2,147, 483, 647 † † Here’s the code to construct a function U (*) that will create such a mapping. † † † PAGE 19 DETERMINISTIC UNCERTAINTIES #include <iostream> // needed for cout #include <cstdlib> // needed for rand() and RAND_MAX using namespace std; double uniform(void); // function U(*) prototype double uniform(void) { return(static_cast<double>(rand()) / RAND_MAX); } // uniform function int main () { cout << uniform() << " is a random number on the interval [0, 1].\n"; } // main function For now, you should be reminded that we are making two very important assumptions about our random number generator: we can generate a random integer between 0 and 2,147, 483, 647 where each integer in this range has an equal chance of occurring and that each call to generate a random integer is independent of the past. † †