Written on October 09, 2002.
• DatePick3, DatePick4
Lottery software to calculate the probability of a pick lottery drawing to match its date (in the American format month, day, year).
(Reposted from PowerBasic forums.)
O glorious computer programmers!
Unhesitant will I be to give a hand away when betting on your programming skills! I wouldn't bet a next century US penny on your math, however!
It is strikingly clear your understanding of theory of probability! Well, then, why so many of you who got into the NY 911 draw debacle? First, cool down. Ignore he who wrote this message. It's been noticed that I bring out the worst in smallness men. Not that I intend it, but I can't present myself in a weak manner. It might be the only reason why stupid numerical relations are advanced insistently — just to negate me! Humans should be different repliers to different posters.
Secondly, let's shoot together the clearest picture of a 3-digit lottery draw. Let's assume it is done once a day, every day of the year. Let's assume just a 365-day year. It's not important if it's a leap year, or the year has 713 days. The programmers always use one variable for multiple values; e.g. Number_Days_In_Year (AS LONG). There are 1000 3-digit combinations, from 000 to 999. Your computer program will treat Total_Pick3_Combs variable as from 0 to 999.
It is easy to be deceived by a probability case of N1 draws simultaneously with N2 draws. This is basic theory of probability. When dealing with simultaneous events, the probability of the combined event is the result of the multiplication of the individual probabilities. Let's take the easiest-to-understand example. Tom tosses his collectible coin. Lance tosses his collectible coin. What is the probability that Bob gets one heads in Tom's toss AND one tails in Lance's toss? The probability to get one heads is 1/2. The probability to get one tails is 1/2. The probability to get simultaneously heads in Tom's AND tails in Lance's is 1/2 * 1/2 = ¼. You can do it no-matter-how-many-gazillions-of-times in a row. The results will always be closely to around ¼ (0.25 or 25%).
Let's use more “complex” situations. Instead of tossing the coin, Tom draws one number from 1 to 365 (drawing one day from a 365-day year). The probability to get any one of the 365 days is 1/365. Instead of tossing the coin, Lance draws one number from 0 to 999 (drawing one pick-3 combination from a total of 1,000). The probability to get any one of the pick3 combinations (straight sets) is 1/1000. The probability of the combined event is clearly 1/365 * 1/1000 = 1/365,000 (simultaneously, that is). Over 99.99% of all schools around the world will come up with the same result. (If not, who knows what institution the tester has been confined to… my way of kidding, when satire can be an efficient tool of the truth...)
It is very easy to think that the probability of drawing one pick-3 combination that matches its numerical date is 1/365 * 1/1000 = 1/365,000. But there are no two simultaneous events. The date is NOT drawn. The date is a datum (given). It's not 1/365, it's 1/1! There is something else, though. Not every day of the year can be expressed as a 3-digit number. But every day of the year can be expressed as a 4-digit number. Consequently, the odds of drawing one pick-3 combination that matches its numerical date is 365/273 * 1000 = 1337 to 1.
Odds or probability? Well, then, the probability is 1 in 1337. On the other hand, there are 365 out of 365 days that can be expressed as 4-digit numbers. The odds of drawing one pick-4 combination that matches its numerical date is 365/365 * 10,000 = 10,000 to 1. Odds or probability? Well, then, the probability is 1 in 10,000.
No theory is valid if invalidated by data. No theory whatsoever is valid if invalidated by data. I wrote two computer programs that simulate exactly drawing one pick-3 or pick-4 combination every day of a 365-day year: DatePick3 and DatePick4. If you divide total cases by number of successes, you'll get closer to the theoretical value of the odds. Run the programs for as many cases as you want. Write down the odds every time. Repeat the process as many times as you want. Average the odds calculated by the programs. The average value will always be as close to the theoretical value of the odds as any theory can be.
There are persons who genuinely believe that random events can take any values at all, especially weird values! Such as billions of consecutive heads in coin tossing! Well, there is an incorruptible law enforcer: standard deviation. Nobody can “bribe” standard deviation! No matter how many times, you, the real-life human, will try a random event, such as coin tossing, the standard deviation will always make sure certain correlations are complied with. You'll toss the coin 1,000 times. The standard deviation makes sure that:
Based on the Normal Probability Rule:
68.2% of the successes will fall within 1 Standard Deviation
from 500 - i.e., between 484 - 516
95.4% of the successes will fall within 2 Standard Deviations
from 500 - i.e., between 468 - 532
99.7% of the successes will fall within 3 Standard Deviations
from 500 - i.e., between 452 - 548.
You'll toss now the coin 1,000,000 times. The standard deviation makes sure that:
The expected (theoretical) number of successes is: 500,000
Based on the Normal Probability Rule:
68.2% of the successes will fall within 1 Standard Deviation
from 500,000 - i.e., between 499,500 - 500,500
95.4% of the successes will fall within 2 Standard Deviations
from 500,000 - i.e., between 499,000 - 501,000
99.7% of the successes will fall within 3 Standard Deviations
from 500,000 - i.e., between 498,500 - 501,500.
Forget about consecutive millions, or billions, or trillions, or googols, or infinite successes or losses! The incorruptible law enforcer standard deviation will never let the laws be broken!
(Run yourself the probability software SuperFormula; it is available from the software download site at SALIU.COM.)
“For only Almighty Number is exactly the same, and at least the same, and at most the same, and randomly the same. May Its Almighty compress the space or expand the time and grant us always our righteous speed! And thus we shall not jump above our thoughts or crawl beneath our feelings.”
Resources in Theory of Probability, Mathematics, Statistics, Combinatorics, Software
See a comprehensive directory of the pages and materials on the subject of theory of probability, mathematics, statistics, combinatorics, plus software.
Of interest: