Web pdp-10.trailing-edge.com

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50110/echain.prb
There are 2 other files named echain.prb in the archive. Click here to see a list.
```100'  NAME--ECHAIN
110'
120'  DESCRIPTION--COMPUTES BASIC QUANTITIES FOF AN ERGODIC MARKOV
130'  CHAIN.
140'
150'  SOURCE--REVISED 11/13/67 BY PROF. KEMENY
160'
170'  INSTRUCTIONS--THE NUMBER OR STATES, N , IS SUPPLIED AS DATA IN
180'  LINE 900.
190'  THE N-BY-N MATRIX P (TRANSITION PROBABILITIES) IS SUPPLIED AS
200'  DATA BY ROWS STARTING IN LINE 9000, OR P MAY BE COMPUTED STARTING
210'  AT 1000.
220'  THE STATES ARE NUMBERED 1 THROUGH N. A MAXIMUM OF 30
230'  STATES ARE ALLOWED. THE PROGRAM COMPUTES THE FUNDAMENTAL QUANTITIES:
240'  LIMITING PROBABILITIES,FUNDAMENTAL MATRIX,POTENTIAL OPERATOR,
250'  MEAN FIRST PASSAGE TIMES, FIRST PASSAGE TIMES IN EQUILIBRIUM,
260'  VARIANCES OF FIRST PASSAGE TIMES, LIMITING VARIANCES,AND
270'  THE TRANSITION MATRIX OF THE REVERSE CHAIN.
280'
290'
300'  *  *  *  *  *  *  *  *  MAIN PROGRAM  *  *  *  *  *  *  *  *  *  *  *
310'
330 DIM P(30,30),M(30,30),Z(30,30),K(30,30),W(30,30)
340 DIM A(1,30),B(1,30)
350 MAT Z=IDN(N,N)
360 MAT A = ZER(1,N)
370 MAT K=ZER(N,N)
380 DATA 3
1010 PRINT "TRANSITION PROBABILITIES"
1020 MAT PRINT P
1030 MAT Z = Z-P
1040 FOR I=1 TO N
1050 LET Z(I,N)=1
1060 NEXT I
1070 MAT M = INV(Z)
1080 FOR J=1 TO N
1090 LET A(1,J)=M(N,J)
1100 NEXT J
1110 GOSUB 1490
1120 PRINT "LIMITING PROBABILITIES"
1130 MAT PRINT A,
1140 MAT M=IDN(N,N)
1150 MAT M = M-P
1160 FOR I=1 TO N
1170 FOR J=1 TO N
1180 LET M(I,J)=M(I,J)+A(1,J)
1190 NEXT J
1200 NEXT I
1210 MAT Z = INV(M)
1220 GOSUB 1490
1230 PRINT "FUNDAMENTAL MATRIX"
1240 MAT PRINT Z
1250 LET Z=Z(1,1)/A(1,1)
1260 FOR I=1 TO N
1270 FOR J=1 TO N
1280 LET K(I,J)=Z*A(1,J)-Z(I,J)
1290 IF ABS(K(I,J))>1E-6  THEN 1310
1300 LET K(I,J)=0
1310 NEXT J
1320 NEXT I
1330 GOSUB 1490
1340 PRINT "POTENTIAL OPERATOR"
1350 MAT PRINT K
1360 FOR I=1 TO N
1370 FOR J=1 TO N
1380 LET M(I,J)=(Z(J,J)-Z(I,J))/A(1,J)
1390 NEXT J
1400 NEXT I
1410 GOSUB 1490
1420 PRINT "MEAN FIRST PASSAGE TIMES"
1430 MAT PRINT M
1440 MAT B = A*M
1450 GOSUB 1490
1460 PRINT "FIRST PASSAGE TIMES IN EQUILIBRIUM"
1470 MAT PRINT B,
1480 GOTO 1530
1490 FOR I=1 TO 3
1500 PRINT
1510 NEXT I
1520 RETURN
1530 MAT K = ZER
1540 FOR I = 1 TO N
1550 LET K(I,I) = 2*Z(I,I)/A(1,I) - 1
1560 NEXT I
1570 MAT W = M*K
1580 FOR I = 1 TO N
1590 LET M(I,I) = 1/A(1,I)
1600 NEXT I
1610 MAT K = Z*M
1620 FOR I = 1 TO N
1630 FOR J = 1 TO N
1640 IF I<>J THEN 1670
1650 LET W(I,J) = 0
1660 GOTO 1690
1670 LET W(I,J) = W(I,J) + 2*(K(I,J)-K(J,J))
1680 LET W(I,J) = W(I,J) - M(I,J)^2
1690 NEXT J
1700 NEXT I
1710 GOSUB 1490
1720 PRINT "VARIANCES OF FIRST PASSAGE TIMES"
1730 PRINT
1740 MAT PRINT W
1750 GOSUB 1490
1760 PRINT "LIMITING VARIANCES"
1770 PRINT
1780 FOR I = 1 TO N
1790 PRINT A(1,I)*(2*Z(I,I)-1-A(1,I)),
1800 NEXT I
1810 PRINT
1820 GOSUB 1490
1830 PRINT "TRANSITION MATRIX OF REVERSE CHAIN"
1840 PRINT
1850 FOR I = 1 TO N
1860 FOR J = 1 TO N
1870 LET K(I,J) = A(1,J)*P(J,I)/A(1,I)
1880 NEXT J
1890 NEXT I
1900 MAT PRINT K
9000 DATA .5,.25,.25
9001 DATA .5,0,.5
9002 DATA .25,.25,.5
9999 END

```