Web pdp-10.trailing-edge.com

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50110/binomd.prb
There are 2 other files named binomd.prb in the archive. Click here to see a list.
```100'  NAME--BINOMD
110'
120'  DESCRIPTION--PREDICTS PROBABILITIES USING BINOMIAL DISTRIBUTION
130'
140'  SOURCE--UNKNOWN
150'
160'  INSTRUCTIONS--USER SUPPLIES AS DATA STARTING IN 900:
170'  N (NUMBER OF TRIALS),P (PROBABILITY OF SUCCESS)
180'  PROGRAM COMPUTES THE PROBABILITY OF EXACTLY I SUCCESSES, AND
190'  I OR MORE SUCCESSES, FOR ALL I.
200'  IT ALSO SHOWS THE STANDARD DEVIATIONS.
210'
220'
230'  *  *  *  *  *  *  *  MAIN PROGRAM   *  *  *  *  *  *  *  *  *  *
240'
250 DIM B(500),C(500)
270 IF N < 125 THEN 300
280 PRINT "N IS TOO LARGE"
290 STOP
300 LET Q = 1-P
310 LET S = SQR(N*P*Q)
320 LET N1 = INT(N*P-4*S)
330 LET N2 = 1+INT(N*P+4*S)
340 LET B(0) = 1
350 FOR I = 1 TO N
360 LET B(I) = B(I-1)*(N-I+1)/I
370 NEXT I
380 IF N1 >= 0 THEN 400
390 LET N1 = 0
400 IF N2 <= N THEN 420
410 LET N2 = N
420 FOR I = N1 TO N2
430 LET B(I) = B(I)*P^I*Q^(N-I)
440 NEXT I
450 LET C(N2) = B(N2)
460 FOR I = N2-1 TO N1 STEP -1
470 LET C(I) = C(I+1) + B(I)
480 NEXT I
490 PRINT "BINOMIAL DISTRIBUTION FOR " N; "TRIALS WITH PROBABILITY" P
500 PRINT
510 PRINT " I       ";
520 PRINT "I SUCCESSES      ";
530 PRINT "I OR MORE SUCC.  ";
540 PRINT "STD. DEVIATIONS"
550 PRINT
560 FOR I = N1 TO N2
570 IF B(I) < 1E-4 THEN 640
580 PRINT I;
590 PRINT "     ";
600 PRINT INT(B(I)*1E4+.5)/1E4,
610 PRINT INT(C(I)*1E4+.5)/1E4,
620 LET S1 = (I-N*P)/S
630 PRINT INT(S1*100+.5)/100
640 NEXT I
900 DATA 10,.2
999 END

```