@@ -9,14 +9,14 @@ function rand(rng::AbstractRNG, ::Random.SamplerTrivial{Random.CloseOpen01{Doubl
9
9
frlo, xplo = frexp (lo)
10
10
xplo = Base. exponent (hi) - min (1 , fld (xplo,4 )) - abs (Base. exponent (eps (hi)))
11
11
lo = ldexp (frlo, xplo)
12
- lo = rand (Bool) ? lo : - lo
12
+ lo = rand (rng, Bool) ? lo : - lo
13
13
14
14
DoubleFloat (hi, lo)
15
15
end
16
16
17
17
function rand (rng:: AbstractRNG , :: Random.SamplerTrivial {Random. CloseOpen01{Complex{DoubleFloat{T}}}}) where {T<: IEEEFloat }
18
- re = rand (DoubleFloat{T})
19
- im = rand (DoubleFloat{T})
18
+ re = rand (rng, DoubleFloat{T})
19
+ im = rand (rng, DoubleFloat{T})
20
20
return Complex {DoubleFloat{T}} (re, im)
21
21
end
22
22
28
28
29
29
function randpm (rng:: MersenneTwister , :: Type{DoubleFloat{T}} ) where {T<: IEEEFloat }
30
30
r = rand (rng, DoubleFloat{T})
31
- r = rand (Bool) ? r : - r
31
+ r = rand (rng, Bool) ? r : - r
32
32
return r
33
33
end
34
34
81
81
# normal variates
82
82
83
83
function randn (rng:: AbstractRNG , :: Type{DoubleFloat{T}} ) where {T<: IEEEFloat }
84
- urand1, urand2 = rand (DoubleFloat{T}, 2 )
84
+ urand1, urand2 = rand (rng, DoubleFloat{T}, 2 )
85
85
urand1 = urand1 + urand1 - 1
86
86
urand2 = urand2 + urand2 - 1
87
87
s = urand1* urand1 + urand2* urand2
88
-
88
+
89
89
while s >= 1 || s === 0
90
- urand1, urand2 = rand (DoubleFloat{T}, 2 )
90
+ urand1, urand2 = rand (rng, DoubleFloat{T}, 2 )
91
91
urand1 = urand1 + urand1 - 1
92
92
urand2 = urand2 + urand2 - 1
93
93
s = urand1* urand1 + urand2* urand2
94
94
end
95
-
95
+
96
96
s = sqrt ( - log (s) / s )
97
97
return (urand1 + urand2) * s
98
98
end
0 commit comments