GoldenSequences.jl icon indicating copy to clipboard operation
GoldenSequences.jl copied to clipboard

AbstractRNG Interface

Open ghost opened this issue 4 years ago • 2 comments

I'd like to use GoldenSequences.jl for quasi-random (low-discrepancy) sequences, but need it to work with AbstractRNG methods such as rand; is there a way to do this?

ghost avatar May 16 '21 00:05 ghost

Do you need a particular sequence such as golden integers or floats or golden tuples of those?

mschauer avatar May 16 '21 05:05 mschauer

In TupleVectors.jl we can do

julia> using TupleVectors, Sobol

julia> ω = SobolHypercube(2)
SobolHypercube{2}(2-dimensional Sobol sequence on [0,1]^2, [0.5, 0.5], Base.RefValue{Int64}(0))

julia> πapprox = @with (;ω) 10000 begin
       x = rand(ω)
       y = rand(ω)
       b = x^2 + y^2 < 1 ? 4 : 0
       (;b)
       end
10000-element TupleVector with schema (b = Int64,)
(b = 3.14±1.6,)

This is still in early stages, and the GoldenSequences instance needs some updating. But I think it already makes things pretty easy.

cscherrer avatar May 19 '21 16:05 cscherrer