Probability theory enters into coin tossing: ie “heads or tails” out of so many tosses. The counting rules for the possible outcome of a 2-outcome trial is 2^n where n is the number of trials. Thus if there are 3 flips the possible combinations would be HHH, HHT, HTH, THH, HTT, THT, TTH, TTT which is 2^3 or 8 combinations. This is describes in an article in ZXAPPEAL, April 86, called PASCAL’S TRIANGLE, which includes a short program to generate the possible combinations for tries ranging from 1 to 8 flips. The combinations are calculated and the calculations produce the chances of each combination appearing.
PASCAL’S TRIANGLE
Blaise Pascal, a French philosopher and mathematician of the 17th century, was for a time interested in games of chance. This interest led him to discover certain important rules about the probabilities of getting heads or tails on the toss of a coin. His findings are described in a triangle formation of numbers which shows easily the chance of getting heads or tails, or any combination of them, on a given number of tosses of a coin.
After running this program you can examine the triangle for these probabilities for as many as 8 tosses. If you make one toss, the chance of getting heads is 1 out of 2. If you toss 2 times your chance of getting 2 heads is 1 out of 4; of getting 1 head and 1 tail, 2 out of 4, and of course 2 tails is 1 out of 4. If you make 3 tosses you get the combinations given in the first paragraph.
10 PRINT "PASCAL'S TRIANGLE"
15 PRINT "First column=Number of Selections"
18 PRINT "second column=Total number possible combinations"
20 PRINT: FOR N=1 TO 8
25 PRINT N;" ";2^N;" ";
30 FOR R=0 TO N
40 LET C=1
50 FOR X=N TO (N-R+1) STEP-1
60 LET C=C*X/(N-X+1)
70 NEXT X
80 PRINT C;" ";
90 NEXT R
100 PRINT:PRINT
110 NEXT N
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.