Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0025/protre.bas
There are 2 other files named protre.bas in the archive. Click here to see a list.
20	DIMJ(9),N(9),I(9),E(9),X(9,40),P(9,40)
40	FORK=1TO9
50	LETN(K)=1
60	LETJ(K)=1
70	LETE(K)=0
80	NEXTK
90	GOTO2380
100	READM
110	IFM>9THEN2340
120	FORQ=1TOM
130	READN(Q)
140	NEXTQ
150	LETB=1
160	FORQ=1TO9
170	LETB=B*N(Q)
180	NEXTQ
190	FOR Q=1TO40
200	FORK=1TO9
210	LETP(K,Q)=1
220	NEXTK
230	NEXTQ
240	LETS1=0
250	LETS2=0
260	LETS3=0
270	LETP1=0
280	DATA 1,1
290	DATA 2,1
300	DATA 3,1
310	DATA 4,1
320	DATA 5,1
330	DATA 6,1
340	DATA 7,1
350	DATA 8,1
360	DATA 9,1
370	FORK=1TO9
380	FORQ=1TON(K)
390	READX(K,Q),P(K,Q)
400	LETE(K)=E(K)+P(K,Q)
410	NEXTQ
420	NEXTK
430	FORK=1TO9
440	FORQ=1TON(K)
450	NEXTQ
460	NEXTK
470	LETJ9=J(9)
480	FORJ9=1TON(9)
490	LETJ8=J(8)
500	FORJ8=1TON(8)
510	LETJ7=J(7)
520	FORJ7=1TON(7)
530	LETJ6=J(6)
540	FORJ6=1TON(6)
550	LETJ5=J(5)
560	FORJ5=1TON(5)
570	LETJ4=J(4)
580	FORJ4=1TON(4)
590	LETJ3=J(3)
600	FORJ3=1TON(3)
610	LETJ2=J(2)
620	FORJ2=1TON(2)
630	LETJ1=J(1)
640	FORJ1=1TON(1)
650	LETV1=X(1,J1)
660	LETV2=X(2,J2)
670	LETV3=X(3,J3)
680	LETV4=X(4,J4)
690	LETV5=X(5,J5)
700	LETV6=X(6,J6)
710	LETV7=X(7,J7)
720	LETV8=X(8,J8)
730	LETV9=X(9,J9)
740	LETU=0
750	LETZ=1
760	LETZ=Z*P(1,J1)
770	LETZ=Z*P(2,J2)
780	LETZ=Z*P(3,J3)
790	LETZ=Z*P(4,J4)
800	LETZ=Z*P(5,J5)
810	LETZ=Z*P(6,J6)
820	LETZ=Z*P(7,J7)
830	LETZ=Z*P(8,J8)
840	LETZ=Z*P(9,J9)
850	LETR1=Z*U
860	LETR2=R1*U
870	LETR3=R2*U
880	LETS1=S1+R1
890	LET S2=S2+R2
900	LETS3=S3+R3
910	LETP1=P1+Z
920	NEXTJ1
930	NEXTJ2
940	NEXTJ3
950	NEXTJ4
960	NEXTJ5
970	NEXTJ6
980	NEXTJ7
990	NEXTJ8
1000	NEXTJ9
1010	IFABS(P1-1)>0.00001THEN2360
1020	LETR1=S1
1030	LET R2=S2-S1^2
1040	LETR3=S3-3*S2*S1+2*S1^3
1050	PRINT
1060	PRINT" P R O B A B I L I T Y   T R E E "
1070	PRINT
1080	PRINT"   VARIABLES:",M
1090	PRINT"    BRANCHES:",B
1100	PRINT
1110	PRINT"       EXPECTED VALUE = ",R1
1120	PRINT"        STD DEVIATION = ",SQR(R2)
1130	PRINT"         STD SKEWNESS = ",R3/((SQR(R2))^3)
1140	PRINT
1150	PRINT
1160	PRINT"PROBABILITY TABLE:"
1170	FORG=1TO9
1180	LETI(G)=1
1190	NEXTG
1200	PRINT
1210	LETI1=I(1)
1220	LETI2=I(2)
1230	LETI3=I(3)
1240	LETI4=I(4)
1250	LETI5=I(5)
1260	LETI6=I(6)
1270	LETI7=I(7)
1280	LETI8=I(8)
1290	LETI9=I(9)
1300	FORI1=1TON(1)
1310	IFM<>1THEN1340
1320	GOSUB2150
1330	NEXTI1
1340	FORI2=1TON(2)
1350	IFM<>2THEN1380
1360	GOSUB2150
1370	NEXTI2
1380	FORI3=1TON(3)
1390	IFM<>3THEN1420
1400	GOSUB2150
1410	NEXTI3
1420	FORI4=1TON(4)
1430	IFM<>4THEN1460
1440	GOSUB2150
1450	NEXTI4
1460	FORI5=1TON(5)
1470	IFM<>5THEN1500
1480	GOSUB2150
1490	NEXTI5
1500	FORI6=1TON(6)
1510	IFM<>6THEN1540
1520	GOSUB2150
1530	NEXTI6
1540	FORI7=1TON(7)
1550	IFM<>7THEN1580
1560	GOSUB2150
1570	NEXTI7
1580	FORI8=1TON(8)
1590	IFM<>8THEN1620
1600	GOSUB2150
1610	NEXTI8
1620	FORI9=1TON(9)
1625	IFM<>9THEN 1650
1630	GOSUB2150
1640	NEXTI9
1650	IFM=9THEN1740
1660	IFM=8THEN1780
1670	IFM=7THEN1820
1680	IFM=6THEN1860
1690	IFM=5THEN1900
1700	IFM=4THEN1940
1710	IFM=3THEN1980
1720	IFM=2THEN2020
1730	IFM=1THEN2050
1740	LETI8=I8+1
1750	IFI8>N(8)THEN1770
1760	GOTO2060
1770	LETI8=1
1780	LETI7=I7+1
1790	IFI7>N(7)THEN1810
1800	GOTO2060
1810	LETI7=1
1820	LETI6=I6+1
1830	IFI6>N(6)THEN1850
1840	GOTO2060
1850	LETI6=1
1860	LETI5=I5+1
1870	IFI5>N(5)THEN1890
1880	GOTO2060
1890	LETI5=1
1900	LETI4=I4+1
1910	IFI4>N(4)THEN1930
1920	GOTO2060
1930	LETI4=1
1940	LETI3=I3+1
1950	IFI3>N(3)THEN1970
1960	GOTO2060
1970	LETI3=1
1980	LETI2=I2+1
1990	IFI2>N(2)THEN2010
2000	GOTO2060
2010	LETI2=1
2020	LETI1=I1+1
2030	IFI1>N(1)THEN2730
2040	GOTO2060
2050	GOTO2730
2060	IFM=1THEN1300
2070	IFM=2THEN1340
2080	IFM=3THEN1380
2090	IFM=4THEN1420
2100	IFM=5THEN1460
2110	IFM=6THEN1500
2120	IFM=7THEN1540
2130	IFM=8THEN1580
2140	IFM=9THEN1620
2150	PRINT
2160	LETP2=1
2170	LETI(1)=I1
2180	LETI(2)=I2
2190	LETI(3)=I3
2200	LETI(4)=I4
2210	LETI(5)=I5
2220	LETI(6)=I6
2230	LETI(7)=I7
2240	LETI(8)=I8
2250	LETI(9)=I9
2260	FORK=1TOM
2270	PRINTX(K,I(K)),
2280	LETP2=P2*P(K,I(K))
2290	NEXTK
2300	PRINT P2
2310	LETB=B-1
2320	IFB=0THEN2730
2330	RETURN
2340	PRINT"PROGRAM HANDLES ONLY 1 TO 9 VARIABLES"
2350	GOTO2730
2360	PRINT"PROBABILITIES DO NOT SUM TO 1 FOR VARIABLE NO.",K
2370	GOTO2730
2380	PRINT
2390	PRINT "THIS PROGRAM COMPUTES THE MEAN, STANDARD DEVIATION,"
2400	PRINT "AND SKEWNESS FOR THE DISTRIBUTION OF ANY FUNCTION OF"
2410	PRINT "UP TO NINE DISCRETE VARIABLES.  EACH VARIABLE MAY"
2420	PRINT "HAVE UP TO 40 VALUES, WITH A FREQUENCY ASSIGNED"
2430	PRINT "TO EACH.  THE END-POINTS OF THE TREE WILL BE COMPUTED"
2440	PRINT "AND ASSIGNED COMPOUND PROBABILITIES ACCORDINGLY."
2450	PRINT " THE DATA FOR A RUN IS ENTERED AS FOLLOWS:"
2460	PRINT
2470	PRINT "    90 DATA M, N1, N2,....., N9"
2480	PRINT "            (WHERE M = NO. OF VARIABLES AND"
2490	PRINT "             VARIABLE 1 HAS N1 VALUES, ETC.)"
2500	PRINT "    280 DATA V1(1),W1(1),V1(2),W1(2),....,V1(N1),W1(N1)"
2510	PRINT "            (WHERE V1(1) IS THE FIRST VALUE OF THE"
2520	PRINT "             FIRST VARIABLE, AND W1(1) IS THE WEIGHT"
2530	PRINT "             OR FREQUENCY ASSIGNED TO THAT VALUE, AND"
2540	PRINT"             SO ON FOR THE OTHER VALUES OF VARIABLE 1.)"
2550	PRINT "    290 DATA (SAME FOR VARIABLE 2)"
2560	PRINT "    300 DATA (SAME FOR VARIABLE 3)"
2570	PRINT "            (AND SO ON FOR THE M VARIABLES.  ADDITIONAL"
2580	PRINT "             VALUES AND WEIGHTS FOR A VARIABLE MAY BE"
2590	PRINT "             ENTERED ON INTERMEDIATELY NUMBERED LINES.)"
2600	PRINT "    740 LET U = A FUNCTION OF V1,V2,V3,....,V9"
2610	PRINT
2620	PRINT "THEN TYPE 'RUN'."
2630	PRINT
2640	PRINT
2650	PRINT "THE PROBABILITY TABLE IS IN THE FORM:"
2660	PRINT
2670	PRINT "  E1     E2     E3 ... EN     P"
2680	PRINT"          ETC."
2690	PRINT
2700	PRINT "WHERE P = PROBABILITY(V1=E1 AND V2=E2 AND ... AND VN=EN)"
2710	PRINT
2720	DATA 0,0,0
2730	END