# RNG in DiscreteProblem solver

**URL:** <https://discourse.julialang.org/t/rng-in-discreteproblem-solver/95929>\
**Category:** Modelling & Simulations\
**Created:** [March 11, 2023, 5:51pm UTC](https://discourse.julialang.org/t/rng-in-discreteproblem-solver/95929 "2023-03-11T17:51:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdwfrost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdwfrost/32/2831_2.png) [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Post date:** [March 11, 2023, 5:51pm UTC](https://discourse.julialang.org/t/rng-in-discreteproblem-solver/95929/1 "2023-03-11T17:51:51Z")

</div>

Hi everyone, I have a DiscreteProblem that uses a random number generator, and I’d like to make it reproducible. In the solver for SDEProblems, I can specify a seed (if not an RNG) - do I need to compose a new init/step! method to maintain a specific RNG?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 11, 2023, 6:37pm UTC](https://discourse.julialang.org/t/rng-in-discreteproblem-solver/95929/2 "2023-03-11T18:37:07Z")

</div>

Is this supposed to be a state space problem?

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdwfrost/32/2831_2.png) [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Post date:** [March 11, 2023, 7:30pm UTC](https://discourse.julialang.org/t/rng-in-discreteproblem-solver/95929/3 "2023-03-11T19:30:59Z")

</div>

It’s basically this model (see code at end)

> [@Tips on (sort of) creating a new Problem type in SciML, derived from an existing type](https://discourse.julialang.org/t/tips-on-sort-of-creating-a-new-problem-type-in-sciml-derived-from-an-existing-type/95749/2):
>
> Is this code cleaner? Is composition the best way here, rather than use traits e.g. via SimpleTraits.jl? I mostly need the types for the time and the state, so the typing should be sufficient. What are the scenarios for using the isinplace type? # TODO: # Add MarkovSystem # Generalize to integer steps # Write integrator struct # Write init and step methods import SciMLBase: DiscreteProblem, ODESolution import OrdinaryDiffEq: solve, FunctionMap import Random: AbstractRNG import Plots: plot str…

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 18, 2023, 10:48am UTC](https://discourse.julialang.org/t/rng-in-discreteproblem-solver/95929/4 "2023-03-18T10:48:46Z")

</div>

Isn’t that the same as what’s handled in DifferenceEquations?

[https://sciml.github.io/DifferenceEquations.jl/dev/](https://sciml.github.io/DifferenceEquations.jl/dev/)
