Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50242/randno.bli
There are no other files named randno.bli in the archive.
00100	%> - - - - RANDOM NUMBER ROUTINES FOR POOMAS - - - - - -
00200	
00300	
00400	<%
00500	MODULE RANDNO(INSPECT,DREGS=5,RSAVE,LOWSEG) =
00600	BEGIN
00700	
00800	EXTERNAL POOLOG,POOEXP,POSQRT,BLIPPERROR;
00900	
01000	MACHOP FADRI = #145;
01100	
01200	MACRO
01300	  BASICDRAW(U,X)=(X_((.U)<0,36>_(30517578125*@.U+7261067085) AND #377777777777);
01400	                 X _ .X^(-8);   X<27,9> _ #200;   .X)$;
01500	
01600	GLOBAL ROUTINE RANDINT(A,B,U) =
01700	BEGIN
01800	  REGISTER X;
01900	  BASICDRAW(U,X);
02000	  .A + FIX ( ( FLOAT (.B - .A + 1) ) FMPR .X)
02100	END;   !   END ROUTINE RANDINT.
02200	
02300	GLOBAL ROUTINE UNIFORM(A,B,U) =
02400	BEGIN
02500	  REGISTER X;
02600	  BASICDRAW(U,X);
02700	  (.X FMPR (.B FSBR .A)) FADR .A
02800	END;   !   END ROUTINE UNIFORM.
02900	
03000	GLOBAL ROUTINE NEGEXP(A,U) =
03100	BEGIN
03200	  REGISTER X;
03300	  BASICDRAW(U,X);
03400	  FADRI(X,0);
03500	  FNEG POOLOG(.X) FDVR .A
03600	END;   !   END OF ROUTINE NEGEXP.
03700	
03800	GLOBAL ROUTINE NORMAL(A,B,U) =
03900	BEGIN
04000	  REGISTER X;
04100	  BASICDRAW(U,X);
04200	  X _ POSQRT(POOLOG(1.0 FDVR (.X FMPR .X)));
04300	  X _ .X FSBR
04400	  (((0.010328 FMPR .X) FADR 0.802853) FMPR .X FADR 2.515517)
04500	    FDVR
04600	  ((((0.001308 FMPR .X) FADR 0.189269) FMPR .X FADR 1.432788)
04700	  FMPR .X FADR 1.0);
04800	  .X FMPR .B FADR .A
04900	END;   !   END ROUTINE NORMAL.
05000	
05100	GLOBAL ROUTINE FASTNORMAL(A,B,U) =
05200	BEGIN
05300	  REGISTER S,X;
05400	  S _ 0.0;
05500	  INCR I FROM 1 TO 4 DO
05600	  ( S _ .S FADR BASICDRAW(U,X));
05700	  .A FADR .B FMPR (.S FSBR 2.0) FMPR 1.73205
05800	END;   !   END ROUTINE FASTNORMAL.
05900	
06000	
06100	GLOBAL ROUTINE ERLANG(A,B,U) =
06200	BEGIN
06300	  REGISTER X,C,S;
06400	  IF .B LSS 0.0 OR .A LSS 0.0 THEN ( BLIPPERROR(#23);  RETURN);
06500	  A _ .A FMPR .B;
06600	  C _ FIX .B;    S _ 1.0;
06700	  INCR I FROM 1 TO .C DO
06800	  ( BASICDRAW(U,X);
06900	    S _ .S FMPR .X
07000	  );
07100	  S _ POOLOG(.S);
07200	  IF (C _ FLOAT .C) EQL .B THEN FNEG (.S FDVR .A)
07300	  ELSE
07400	  ( BASICDRAW(U,X);
07500	    FNEG ((POOLOG(.X) FMPR (.B FSBR .C) FADR .S) FDVR .A))
07600	END;   !   END ROUTINE ERLANG.
07700	
07800	GLOBAL ROUTINE POISSON(A,U) =
07900	BEGIN
08000	  REGISTER X,N,P;
08100	  IF .A LSS 0.0 THEN RETURN 0;
08200	  IF .A GTR 20.0 THEN RETURN FIX NORMAL(.A,POSQRT(.A),.U);
08300	  N _ 0;    P _ 1.0;
08400	  A _ POOEXP(FNEG .A);
08500	  UNTIL .P LSS .A DO
08600	  ( BASICDRAW(U,X);
08700	    P _ .P FMPR .X;
08800	    N _ .N+1
08900	  );
09000	  .N
09100	END;   !   END ROUTINE POISSON.
09200	
09300	GLOBAL ROUTINE DISCRETE(A,N,U) =
09400	BEGIN
09500	  REGISTER X;
09600	  BASICDRAW(U,X);
09700	  FADRI(X,0);
09800	  INCR I FROM 0 TO .N DO
09900	    IF @(.A)[.I] GTR .X THEN RETURN .I;
10000	  .N+1
10100	END;   !   END ROUTINE DISCRETE.
10200	
10300	GLOBAL ROUTINE LINEAR(A,B,N,U) =
10400	BEGIN
10500	  REGISTER J,X;
10600	  BASICDRAW(U,X);
10700	  FADRI(X,0);
10800	  J _ ( INCR I FROM 0 TO .N DO
10900	          IF @(.A)[.I] GTR .X THEN EXITCOMPOUND .I;
11000	        BLIPPERROR(#24);   RETURN @(.B)[.N]
11100	      );
11200	  @(.B)[.J-1] FADR ((.X FSBR @(.A)[.J-1])
11300	    FMPR (@(.B)[.J] FSBR @(.B)[.J-1]))
11400	    FDVR (@(.A)[.J] FSBR @(.A)[.J-1])
11500	END;   !   END ROUTINE LINEAR.
11600	
11700	END
11800	ELUDOM