mschauer / GoldenSequences.jl

Generalized golden sequences, a form of low discrepancy sequence or quasi random numbers
MIT License
18 stars 3 forks source link

AbstractRNG Interface #6

Open ghost opened 3 years ago

ghost commented 3 years ago

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?

mschauer commented 3 years ago

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

cscherrer commented 3 years ago

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.