@@ -16,15 +16,18 @@ rand_tangent(rng::AbstractRNG, x::Integer) = NoTangent()
1616# Try and make nice numbers with short decimal representations for good error messages
1717# while also not biasing the sample space too much
1818function rand_tangent (rng:: AbstractRNG , x:: T ) where {T<: Number }
19- return round (8 randn (rng, T), sigdigits= 5 , base= 2 )
19+ # multiply by 9 to give a bigger range of values tested: no so tightly clustered around 0.
20+ return round (9 * randn (rng, T), sigdigits= 5 , base= 2 )
2021end
2122rand_tangent (rng:: AbstractRNG , x:: Float64 ) = rand (rng, - 9 : 0.01 : 9 )
2223function rand_tangent (rng:: AbstractRNG , x:: ComplexF64 )
2324 return ComplexF64 (rand (rng, - 9 : 0.1 : 9 ), rand (rng, - 9 : 0.1 : 9 ))
2425end
2526
2627# BigFloat/MPFR is finicky about short numbers, this doesn't always work as well as it should
27- rand_tangent (rng:: AbstractRNG , :: BigFloat ) = round (big (8 randn (rng)), sigdigits= 5 , base= 2 )
28+
29+ # multiply by 9 to give a bigger range of values tested: no so tightly clustered around 0.
30+ rand_tangent (rng:: AbstractRNG , :: BigFloat ) = round (big (9 * randn (rng)), sigdigits= 5 , base= 2 )
2831
2932rand_tangent (rng:: AbstractRNG , x:: StridedArray ) = rand_tangent .(Ref (rng), x)
3033rand_tangent (rng:: AbstractRNG , x:: Adjoint ) = adjoint (rand_tangent (rng, parent (x)))
0 commit comments