相关代码 |
|
Function GASDEV(IDUM&) Static ISET, GSET If ISET = 0 Then Do V1 = 2# * RAN1(IDUM&) - 1# V2 = 2# * RAN1(IDUM&) - 1# R = V1 ^ 2 + V2 ^ 2 Loop While R >= 1# Or R = 0 FAC = Sqr(-2# * Log(R) / R) GSET = V1 * FAC GASDEV = V2 * FAC ISET = 1 Else GASDEV = GSET ISET = 0 End If End Function