Program Printout: Probability

Publication: Timex Sinclair User
Pub Details: Timex Sinclair User n1 (Volume 1, Issue 1)
Date: June 1983
Pages: 35
When will it happen again? Dice, roulette wheel, racehorse, greyhound and cards
When will it happen again? Dice, roulette wheel, racehorse, greyhound and cards

POISSON’S FORMULA is a method of calculating the possibilities of recurrence of an event, based on the number of occurrences in the past.

For this listing, the time should be adjusted so that the number of occurrences is in the range 3 to 12. The range could be extended upwards if required, but 2 has been omitted as it would mean an unreliably small sample.

The formula here is applied with a correction factor but that will not distort the results, since the same percentage is applied to all answers, thus keeping them in the same proportion. (1K T/S1000,ZX81)

  9 CLEAR
10 PRINT " LONG TERM PROBABILITY STUDY"
11 LET S=0
12 LET T=0
13 LET U=0
14 LET V=0
15 LET W=0
16 LET X=0
17 LET Y=0
18 LET Z=0
20 LET AA=0
22 LET BB=0
25 PRINT
30 PRINT "INPUT THE MAXIMUM OCCURRENCES IN ANY ONE UNIT OF TIME "
31 PRINT
32 PRINT " RANGE ALLOWED 3 TO 12"
40 INPUT A
45 CLS
50 PRINT "INPUT TOTAL OCCURENCES"
60 INPUT B
70 PRINT
80 PRINT "INPUT TOTAL TIME"
90 INPUT C
95 CLS
100 LET D=B/C
110 LET E=(1+(1/B))**B
120 LET F=1/(E**D)
130 LET P=F
140 LET Q=D*F
150 LET R=D**2/2*F
160 IF A>=3 THEN LET S=D**3/6*F
170 IF A>=4 THEN LET T=D**4/24*F
180 IF A>=5 THEN LET U=D**5/120*F
190 IF A>=6 THEN LET V=D**6/720*F
200 IF A>=7 THEN LET W=D**7/5040*F
210 IF A>=8 THEN LET X=D**8/40320*F
220 IF A>=9 THEN LET Y=D**9/362880*F
230 IF A>=10 THEN LET Z=D**10/3628800*F
233 IF A>=11 THEN LET AA=D**11/39916800*F
237 IF A=12 THEN LET BB=D**12/479001600*F
240 PRINT "PROBABILITY OF","PERCENT"
250 PRINT
252 REM CORRECTION FACTOR
255 LET N=P+Q+R+S+T+U+V+W+X+Y+Z+AA+BB
260 LET PP=(INT (P*10000/N+0.5))/100
270 LET QQ=(INT (Q*10000/N+0.5))/100
280 LET RR=(INT (R*10000/N+0.5))/100
290 LET SS=(INT (S*10000/N+0.5))/100
300 LET TT=(INT (T*10000/N+0.5))/100
310 LET UU=(INT (U*10000/N+0.5))/100
320 LET VV=(INT (V*10000/N+0.5))/100
330 LET WW=(INT (W*10000/N+0.5))/100
340 LET XX=(INT (X*10000/N+0.5))/100
350 LET YY=(INT (Y*10000/N+0.5))/100
360 LET ZZ=(INT (Z*10000/N+0.5))/100
363 LET AAA=(INT (AA*10000/N+0.5))/100
366 LET BBB=(INT (BB*10000/N+0.5))/100
370 LET A$="0 OCCURRENCES"
380 LET B$="1 """
390 LET C$="2 """
400 LET D$="3 """
410 LET E$="4 """
420 LET F$="5 """
430 LET G$="6 """
440 LET H$="7 """
450 LET I$="8 """
451 LET J$="9 """
452 LET K$="10 """
455 LET L$="11 """
457 LET M$="12 """
570 PRINT A$,PP,B$,QQ,C$,RR,D$,SS,E$,TT,F$,UU,G$,VV,H$,WW,I$,XX,J$,YY,K$,ZZ,L$,AAA,M$,BBB,,,PP+QQ+RR+SS+TT+UU+VV+WW+XX+YY+ZZ+AAA+BBB

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.