Skip to content

Using TaskLocalRNG results in identical noise across processes #258

@isaacsas

Description

@isaacsas

When multiple noise processes are created sequentially with the default TaskLocalRNG or a user passed TaskLocalRNG and no intervening rand calls, copy(rng) gives each process an identical RNG state, resulting in statistically identical samples.

using DiffEqBase, DiffEqNoiseProcess

# Create two WienerProcesses back-to-back with default RNG
W1 = WienerProcess(0.0, 0.0, 0.0; reseed = false)
W2 = WienerProcess(0.0, 0.0, 0.0; reseed = false)
sol1 = solve(NoiseProblem(W1, (0.0, 1.0)); dt = 0.1)
sol2 = solve(NoiseProblem(W2, (0.0, 1.0)); dt = 0.1)

println("W1 samples: ", sol1.W)
println("W2 samples: ", sol2.W)
println("Identical?  ", sol1.W == sol2.W)

Output (v5.27.0): Identical? true — both processes produce the exact same noise samples.

This is due to the changes made in c305243

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions