https://github.com/dmetivie/randomizedquasimontecarlo.jl

Some randomization methods for Randomized Quasi Monte Carlo e.g. scrambling, shift

https://github.com/dmetivie/randomizedquasimontecarlo.jl

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: springer.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.9%) to scientific vocabulary

Keywords

julia julia-language monte-carlo quasi-monte-carlo scrambling
Last synced: 8 months ago · JSON representation

Repository

Some randomization methods for Randomized Quasi Monte Carlo e.g. scrambling, shift

Basic Info
  • Host: GitHub
  • Owner: dmetivie
  • License: mit
  • Language: Julia
  • Default Branch: master
  • Homepage:
  • Size: 2.09 MB
Statistics
  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 3
Topics
julia julia-language monte-carlo quasi-monte-carlo scrambling
Created about 4 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Authors

README.md

RandomizedQuasiMonteCarlo

This package is now deprecated. It has been "merged" with the QuasiMonteCarlo.jl package with PR57 All the randomization methods are now available there see the doc.


The purpose of this package is to provide randomization method of low discrepancy sequences.

So far only nested uniform scrambling, Cranley Patterson Rotation (shift mod 1) and Linear Matrix Scrambling.

Compared to over Quasi Monte Carlo package the focus here is not to generate low discrepancy sequences (ξ₁, ..., ξₙ) (Sobol', lattice, ...) but on randomization of these sequences (ξ₁, ..., ξₙ) → (x₁, ..., xₙ). The purpose is to obtain many independent realizations of (x₁, ..., xₙ) by using the functions shift!, scrambling!, etc. The original sequences can be obtained for example via the QuasiMonteCarlo.jl package.

The scrambling codes are inspired from Owen's R implementation that can be found here.

Basic examples

```julia using RandomizedQuasiMonteCarlo, QuasiMonteCarlo m = 7 N = 2^m # Number of points d = 2 # dimension M = 32 # Number of bit to represent a digit b = 2 # Base uuniform = rand(N, d) # i.i.d. uniform usobol = permutedims(QuasiMonteCarlo.sample(N, zeros(d), ones(d), SobolSample())) # I should update the convention in my pkg to have dim × n and not n × dim unus = nesteduniformscramble(usobol; M=M) ulms = linearmatrixscramble(usobol, b; M=M) udigitalshift = digitalshift(usobol, b; M=M) ushift = shift(usobol)

Plot

using Plots, LaTeXStrings

Settings I like for plotting

default(fontfamily="Computer Modern", linewidth=1, label=nothing, grid=true, framestyle=:default)

begin d1 = 1 d2 = 2 sequences = [uuniform, usobol, unus, ulms, ushift, udigitalshift] names = ["Uniform", "Sobol (unrandomized)", "Nested Uniform Scrambling", "Linear Matrix Scrambling", "Shift", "Digital Shift"] p = [plot(thicknessscaling=2, aspect_ratio=:equal) for i in sequences] for (i, x) in enumerate(sequences) scatter!(p[i], x[:, d1], x[:, d2], ms=0.9, c=1, grid=false) title!(names[i]) xlims!(p[i], (0, 1)) ylims!(p[i], (0, 1)) yticks!(p[i], [0, 1]) xticks!(p[i], [0, 1]) hline!(p[i], range(0, 1, step=1 / 4), c=:gray, alpha=0.2) vline!(p[i], range(0, 1, step=1 / 4), c=:gray, alpha=0.2) hline!(p[i], range(0, 1, step=1 / 2), c=:gray, alpha=0.8) vline!(p[i], range(0, 1, step=1 / 2), c=:gray, alpha=0.8) end plot(p..., size=(1500, 900)) end ```

different_scrambling_N_128.svg

Scrambling of Faure sequences in base b

Now let say you want to do scrambling in base b.

julia using QuasiMonteCarlo using Random

The InertSampler is used to obtain a randomized Faure sequences (see here in the test file).

julia struct InertSampler <: Random.AbstractRNG end InertSampler(args...; kwargs...) = InertSampler() Random.rand(::InertSampler, ::Type{T}) where {T} = zero(T) Random.shuffle!(::InertSampler, arg::AbstractArray) = arg

```julia m = 4 d = 3 b = QuasiMonteCarlo.nextprime(d) N = b^m # Number of points M = m rng = InertSampler()

Unrandomized low discrepency sequence

u_faure = permutedims(QuasiMonteCarlo.sample(N, d, FaureSample(rng)))

Randomized version

unus = nesteduniformscramble(ufaure, b; M=M) ulms = linearmatrixscramble(ufaure, b; M=M) udigitalshift = digitalshift(ufaure, b; M=M)

```

This plot checks (visually) that you are dealing with $(t,d,m)$ sequence i.e. you must see one point per rectangle.

```julia begin d1 = 1 d2 = 3 x = ulms p = [plot(thicknessscaling=2, aspect_ratio=:equal) for i in 0:m] for i in 0:m j = m - i xᵢ = range(0, 1, step=1 / b^(i)) xⱼ = range(0, 1, step=1 / b^(j)) scatter!(p[i+1], x[:, d1], x[:, d2], ms=2, c=1, grid=false) xlims!(p[i+1], (0, 1.01)) ylims!(p[i+1], (0, 1.01)) yticks!(p[i+1], [0, 1]) xticks!(p[i+1], [0, 1]) hline!(p[i+1], xᵢ, c=:gray, alpha=0.2) vline!(p[i+1], xⱼ, c=:gray, alpha=0.2) end plot(p..., size=(1500, 900)) end

```

equapartition_lms_m_4_d_3.svg

Multiple randomization

In case you need to repeat randomization several times, I suggest you use in place functions and compute some stuff in advance e.g. bit expansion of your initial set of point to be randomized, the which_permutation function used in Nested Uniform Scrambling.

julia unrandomized_bits = sobol_pts2bits(m, d, M)

Here I use directly the bit representation for Sobol sequence. I could have done like in previous example and import the Sobol sequence from QuasiMonteCarlo.jl (which calls Sobol.jl). Note that you can call any sequence of point into its bit representation with points2bits function.

```julia randombits = similar(unrandomizedbits) indices = whichpermutation(unrandomizedbits) # This function is used in Nested Uniform Scramble. I nus = NestedUniformScrambler(unrandomizedbits, indices) lms = LinearMatrixScrambler(unrandomizedbits)

usob = dropdims(mapslices(bits2unif, unrandomizedbits, dims=3), dims=3) unus = copy(usob) ulms = copy(usob) ushift = copy(usob)

NumberOfRand = 100

for j in 1:NumberOfRand scramble!(unus, randombits, nus) scramble!(ulms, randombits, lms) shift!(u_shift) end

```

Owner

  • Name: David Métivier
  • Login: dmetivie
  • Kind: user
  • Location: Montpellier, France
  • Company: INRAe, MISTEA

I am a research scientist with a physics background. Now, I do statistics to tackle environmental, and climate change problems. Julia enthusiast!

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 47
  • Total Committers: 3
  • Avg Commits per committer: 15.667
  • Development Distribution Score (DDS): 0.106
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
David Métivier 4****e@u****m 42
CompatHelper Julia c****y@j****g 3
David 4****e@u****m 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 2
  • Total pull requests: 3
  • Average time to close issues: 8 months
  • Average time to close pull requests: about 14 hours
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 6.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ParadaCarleton (1)
  • JuliaTagBot (1)
Pull Request Authors
  • github-actions[bot] (3)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 5
juliahub.com: RandomizedQuasiMonteCarlo

Some randomization methods for Randomized Quasi Monte Carlo e.g. scrambling, shift

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 9.9%
Dependent packages count: 38.9%
Average: 43.9%
Forks count: 53.5%
Stargazers count: 73.2%
Last synced: 8 months ago

Dependencies

.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/CompatHelper.yml actions