相关代码 |
|
Function GASDEV:real; var V1,V2,FAC,R:real; begin If ISET^= 0 Then begin repeat V1:=2 * Random - 1; V2:=2 * Random - 1; R:=Sqr(V1) + Sqr(V2); until (R < 1); FAC:=Sqrt(-2 * Ln(R) / R); GSET^:=V1 * FAC; GASDEV:=V2 * FAC; ISET^:=1; end Else begin GASDEV:=GSET^; ISET^:=0; end; end;