Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50110/binomi.tuk
There are 2 other files named binomi.tuk in the archive. Click here to see a list.
10' NAME--BINOMI
20'
30' DESCRIPTION--COMPUTES AND PRINTS BINOMIAL PROBABILITIES
40' 
50' SOURCE--UNKNOWN
60'
70' INSTRUCTIONS--TYPE RUN TO USE
80'
90' THIS PROGRAM WAS WRITTEN FOR STUDENT USE AT AMOS TUCK SCHOOL
92' OF HANOVER,N.H., WHICH DOES NOT ASSUME RESPONSIBIBLITY FOR
94' ITS ACCURACY.
100'
110' * * * * * * * * * * * MAIN PROGRAM * * * * * * * * * * * * * 
120'
130 PRINT "THIS PROGRAM PRINTS A TABLE OF BINOMIAL PROBABILITIES FOR ANY"
140 PRINT "RANGE OF R (NUMBER OF 'SUCCESSES'), GIVEN P, THE PROBABILITY OF"
150 PRINT "SUCCESS ON EACH TRIAL, AND N, THE NUMBER OF TRIALS."
160 PRINT
170 PRINT "N,P =";
180 INPUT N,P
190 PRINT
200 IF ABS(INT(N)) = N THEN 220
210 PRINT "N MUST BE A POSITIVE INTEGER--TRY AGAIN."
215 GO TO 170
220 IF P<1 THEN 240
230 PRINT "P MUST BE LESS THAN UNITY--TRY AGAIN."
235 GO TO 170
240 IF P>0 THEN 270
250 PRINT "P MUST BE GREATER THAN ZERO--TRY AGAIN."
260 GO TO 170
270 PRINT "GIVE THE LOWER AND UPPER R'S THAT INTEREST YOU";
280INPUT R1,R2
285 PRINT
290 IF ABS(INT(R1))=R1 THEN 310
300 PRINT "THE R'S MUST BE POSITIVE INTEGERS--TRY AGAIN."
305 GO TO 270
310 IF ABS(INT(R2))=R2 THEN 330
320 GO TO 300
330 IF R1<=R2 THEN 350
340 PRINT "THE FIRST R MUST BE NO GREATER THAN THE SECOND R--TRY AGAIN."
345 GO TO 270
350 IF R2<=N THEN 390
360 PRINT "THE SECOND R MUST BE NO GREATER THAN N--TRY AGAIN."
370 GO TO 270
380  
390 PRINT
400 PRINT
410 PRINT "N ="N
420 PRINT "P ="P
430 PRINT "TABLE FOR R ="R1"THRU"R2
440 PRINT
450 PRINT
460 PRINT " R             P(#SUCC.=R)     P(#SUCC.<=R)    P(#SUCC.>=R)"
465 PRINT " -             -----------     ------------    ------------"
470 PRINT
473 LET C1 = 0
478 LET C2 = 1
480 FOR I = 0 TO R1 -1
490     GOSUB 1000
500 NEXTI
520 FOR I = R1 TO R2
530     GOSUB 1000
540     PRINT I,U,C1,C2+U
550 NEXT I
560 STOP
570  
1000 LET U = (1-P)^(N-I-I)
1010 FOR J = 1 TO I
1020     LET U = U*((N-I+J)/J)*P*(1-P)
1030 NEXT J
1040 LET C1 = C1+U
1050 LET C2 = C2-U
1060 RETURN
1070  
9000 END