Skip to content

Commit 90a292b

Browse files
Merge pull request #224 from SciML/pr-223
Finish RandomNumbers.jl removal: Replace Xorshifts RNG with Random.default_rng()
2 parents 3a5ccf4 + 2074b84 commit 90a292b

File tree

9 files changed

+26
-31
lines changed

9 files changed

+26
-31
lines changed

Project.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ PoissonRandom = "e409e4f3-bfea-5376-8464-e040bb5c01ab"
1414
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
1515
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1616
Random123 = "74087812-796a-5b5d-8853-05524746bad3"
17-
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
1817
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1918
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2019
ResettableStacks = "ae5879a3-cd67-5da8-be7f-38c6eb64a37b"
@@ -36,7 +35,6 @@ Optim = "1"
3635
PoissonRandom = "0.4"
3736
QuadGK = "2"
3837
Random123 = "1.2"
39-
RandomNumbers = "1.3"
4038
RecipesBase = "0.7, 0.8, 1.0"
4139
RecursiveArrayTools = "2, 3"
4240
ResettableStacks = "0.6, 1.0"
@@ -51,7 +49,6 @@ Cubature = "667455a9-e2ce-5579-9412-b964f529a492"
5149
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
5250
HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
5351
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
54-
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
5552
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
5653
SDEProblemLibrary = "c72e72a9-a271-4b2b-8966-303ed956772e"
5754
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -60,4 +57,4 @@ StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
6057
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6158

6259
[targets]
63-
test = ["Test", "SDEProblemLibrary", "Pkg", "StatsBase", "StaticArrays", "StochasticDiffEq", "Distributions", "HypothesisTests", "Cubature", "RandomNumbers"]
60+
test = ["Test", "SDEProblemLibrary", "Pkg", "StatsBase", "StaticArrays", "StochasticDiffEq", "Distributions", "HypothesisTests", "Cubature"]

src/DiffEqNoiseProcess.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ using ResettableStacks, DiffEqBase, RecipesBase
44
using RecursiveArrayTools, StaticArraysCore, Random, Statistics
55
using LinearAlgebra
66

7-
import RandomNumbers: Xorshifts
8-
9-
import RandomNumbers, Random123
7+
import Random123
108

119
import DiffEqBase: isinplace,
1210
solve, AbstractNoiseProcess,

src/correlated_noisefunc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CorrelatedWienerProcess!(Γ,t0,W0,Z0=nothing;kwargs...)
2626
where `Γ` is the constant covariance matrix.
2727
"""
2828
function CorrelatedWienerProcess(Γ, t0, W0, Z0 = nothing;
29-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
29+
rng = Random.default_rng())
3030
NoiseProcess{false}(t0, W0, Z0, construct_correlated_noisefunc(Γ)..., rswm = RSWM(),
3131
rng = rng, covariance = Γ)
3232
end
@@ -58,7 +58,7 @@ CorrelatedWienerProcess!(Γ,t0,W0,Z0=nothing;kwargs...)
5858
where `Γ` is the constant covariance matrix.
5959
"""
6060
function CorrelatedWienerProcess!(Γ, t0, W0, Z0 = nothing;
61-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
61+
rng = Random.default_rng())
6262
NoiseProcess{true}(t0, W0, Z0, construct_correlated_noisefunc!(Γ)...,
6363
rswm = RSWM(), rng = rng, covariance = Γ)
6464
end

src/noise_interfaces/virtual_brownian_tree_interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function split_VBT_seed(rng::Random123.AbstractR123, parent_seed, current_depth,
156156
# seed right
157157
seed_r = convert(typeof(parent_seed), parent_seed + (Nt - 1) ÷ 2^(current_depth + 1))
158158

159-
RandomNumbers.Random123.set_counter!(rng, parent_seed)
159+
Random123.set_counter!(rng, parent_seed)
160160
return seed_l, seed_r, parent_seed
161161
end
162162

src/pCN.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function pCN(source::AbstractNoiseProcess{T, N, Vector{T2}, inplace}, ρ;
5252
end
5353

5454
"""
55-
pCN(noise::NoiseGrid, ρ; reset=true, rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
55+
pCN(noise::NoiseGrid, ρ; reset=true, rng = Random.default_rng())
5656
5757
Create a new, but correlated noise process from `noise` and additional entropy with correlation ρ.
5858
This update defines an autoregressive process in the space of Wiener (or noise process) trajectories, which can be used as proposal distribution in Metropolis-Hastings algorithms (often called the "preconditioned Crank–Nicolson scheme".)
@@ -62,7 +62,7 @@ External links
6262
- [Preconditioned Crank–Nicolson algorithm on Wikipedia](https://en.wikipedia.org/wiki/Preconditioned_Crank%E2%80%93Nicolson_algorithm)
6363
"""
6464
function pCN(source::NoiseGrid, ρ; reset = true,
65-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
65+
rng = Random.default_rng())
6666

6767
# generate new Wiener process similar to the one in source
6868
t = source.t

src/types.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A `NoiseProcess` is a type defined as:
1212
NoiseProcess(t0, W0, Z0, dist, bridge;
1313
iip = SciMLBase.isinplace(dist, 3),
1414
rswm = RSWM(), save_everystep = true,
15-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
15+
rng = Random.default_rng(),
1616
reset = true, reseed = true)
1717
```
1818
@@ -188,7 +188,7 @@ end
188188

189189
function NoiseProcess{iip}(t0, W0, Z0, dist, bridge;
190190
rswm = RSWM(), save_everystep = true, covariance = nothing,
191-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
191+
rng = Random.default_rng(),
192192
reset = true, reseed = true, continuous = true,
193193
cache = nothing) where {iip}
194194
S₁ = ResettableStacks.ResettableStack{iip}(Tuple{typeof(t0), typeof(W0), typeof(Z0)
@@ -327,7 +327,7 @@ Like `NoiseProcess` but without support for adaptivity. This makes it lightweigh
327327
```julia
328328
SimpleNoiseProcess{iip}(t0, W0, Z0, dist, bridge;
329329
save_everystep = true,
330-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
330+
rng = Random.default_rng(),
331331
reset = true, reseed = true) where {iip}
332332
```
333333
@@ -371,7 +371,7 @@ mutable struct SimpleNoiseProcess{
371371

372372
function SimpleNoiseProcess{iip}(t0, W0, Z0, dist, bridge;
373373
save_everystep = true, covariance = nothing,
374-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
374+
rng = Random.default_rng(),
375375
reset = true, reseed = true) where {iip}
376376
if Z0 == nothing
377377
Z = nothing
@@ -698,7 +698,7 @@ NoiseTransport{iip}(t0,
698698
RV,
699699
rv,
700700
Z = nothing;
701-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
701+
rng = Random.default_rng(),
702702
reset = true,
703703
reseed = true,
704704
noise_prototype = W(nothing, nothing, t0, rv)) where {iip}
@@ -708,7 +708,7 @@ NoiseTransport{iip}(t0,
708708
NoiseTransport(t0,
709709
W,
710710
RV;
711-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
711+
rng = Random.default_rng(),
712712
reset = true,
713713
reseed = true,
714714
kwargs...)
@@ -793,7 +793,7 @@ mutable struct NoiseTransport{T, N, wType, zType, Tt, T2, T3, TRV, Trv, RNGType,
793793
reseed::Bool
794794

795795
function NoiseTransport{iip}(t0, W, RV, rv, Z = nothing;
796-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
796+
rng = Random.default_rng(),
797797
reset = true, reseed = true,
798798
noise_prototype = W(nothing, nothing, t0, rv)) where {iip}
799799
curt = t0
@@ -841,13 +841,13 @@ function (W::NoiseTransport)(out1, out2, u, p, t, rv)
841841
end
842842

843843
function NoiseTransport(t0, W, RV, rv, Z = nothing;
844-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)), reset = true,
844+
rng = Random.default_rng(), reset = true,
845845
reseed = true, kwargs...)
846846
iip = DiffEqBase.isinplace(W, 5)
847847
NoiseTransport{iip}(t0, W, RV, rv, Z; rng, reset, reseed, kwargs...)
848848
end
849849

850-
function NoiseTransport(t0, W, RV; rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
850+
function NoiseTransport(t0, W, RV; rng = Random.default_rng(),
851851
reset = true, reseed = true, kwargs...)
852852
iip = DiffEqBase.isinplace(W, 5)
853853
rv = RV(rng)
@@ -1155,7 +1155,7 @@ function VirtualBrownianTree{iip}(t0, W0, Z0, dist, bridge;
11551155
tend = nothing, Wend = nothing, Zend = nothing,
11561156
atol = 1e-10, tree_depth::Int = 4,
11571157
search_depth = nothing,
1158-
rng = RandomNumbers.Random123.Threefry4x(),
1158+
rng = Random123.Threefry4x(),
11591159
reset = true) where {iip}
11601160
if search_depth == nothing
11611161
if atol < 1e-10
@@ -1260,7 +1260,7 @@ BoxWedgeTail{iip}(t0, W0, Z0, dist, bridge;
12601260
box_grouping = :MinEntropy,
12611261
sqeezing = true,
12621262
save_everystep = true,
1263-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
1263+
rng = Random.default_rng(),
12641264
reset = true, reseed = true) where {iip}
12651265
```
12661266
"""
@@ -1311,7 +1311,7 @@ function BoxWedgeTail{iip}(t0, W0, Z0, dist, bridge;
13111311
box_grouping = :MinEntropy,
13121312
sqeezing = true,
13131313
save_everystep = true,
1314-
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)),
1314+
rng = Random.default_rng(),
13151315
reset = true, reseed = true) where {iip}
13161316
if Z0 === nothing
13171317
Z = nothing

test/VBT_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "Virtual Brownian Tree tests" begin
22
using DiffEqNoiseProcess, DiffEqBase, StochasticDiffEq, Test, Random
3-
import RandomNumbers, Random123
3+
import Random123
44

55
W = VirtualBrownianTree(0.0, 0.0; tree_depth = 3, search_depth = 5)
66
@test isinplace(W) == false
@@ -20,7 +20,7 @@
2020
@test_throws ErrorException accept_step!(W, dt, nothing, nothing)
2121

2222
# test interpolation/binary search
23-
rng = RandomNumbers.Random123.Threefry4x() # instantiate PRNG
23+
rng = Random123.Threefry4x() # instantiate PRNG
2424
rngcopy = copy(rng)
2525
W = VirtualBrownianTree(0.0, 0.0; tree_depth = 1, search_depth = 5, rng = rng)
2626
t = (W.t[2] - W.t[1]) / 8

test/noise_wrapper.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DiffEqNoiseProcess, Test, Random, RandomNumbers
1+
using DiffEqNoiseProcess, Test, Random
22
using StochasticDiffEq, LinearAlgebra
33
@testset "NoiseWrapper" begin
44
_W = WienerProcess(0.0, 0.0, 0.0)
@@ -286,7 +286,7 @@ end
286286

287287
W = WienerProcess(t, rand_prototype,
288288
save_everystep = save_noise,
289-
rng = Xorshifts.Xoroshiro128Plus(_seed))
289+
rng = Random.default_rng())
290290
prob = NoiseProblem(W, (0.0, 1.0))
291291
W2 = solve(prob; dt = 0.1)
292292
bW = DiffEqNoiseProcess.vec_NoiseProcess(W2)

test/two_processes.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using StochasticDiffEq, DiffEqNoiseProcess, Test, LinearAlgebra
2-
using Random, RandomNumbers
2+
using Random, Random123
33
seed = 100;
44
Random.seed!(seed);
55
@testset "Two noise processes for different m" begin
@@ -10,14 +10,14 @@ Random.seed!(seed);
1010
Random.seed!(seed)
1111
W = WienerProcess!(0.0, rand_prototype, rand_prototype2,
1212
save_everystep = true,
13-
rng = Xorshifts.Xoroshiro128Plus(seed))
13+
rng = Random123.Threefry4x())
1414
prob = NoiseProblem(W, (0.0, 1.0))
1515
sol = solve(prob; dt = 0.2)
1616

1717
Random.seed!(seed)
1818
Woop = WienerProcess(0.0, rand_prototype, rand_prototype2,
1919
save_everystep = true,
20-
rng = Xorshifts.Xoroshiro128Plus(seed))
20+
rng = Random123.Threefry4x())
2121
proboop = NoiseProblem(Woop, (0.0, 1.0))
2222
soloop = solve(proboop; dt = 0.2)
2323

0 commit comments

Comments
 (0)