# How to get a new, independent, randomly initialized RNG

**URL:** <https://discourse.julialang.org/t/how-to-get-a-new-independent-randomly-initialized-rng/7310>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 25, 2017, 7:48pm UTC](https://discourse.julialang.org/t/how-to-get-a-new-independent-randomly-initialized-rng/7310 "2017-11-25T19:48:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 25, 2017, 7:48pm UTC](https://discourse.julialang.org/t/how-to-get-a-new-independent-randomly-initialized-rng/7310/1 "2017-11-25T19:48:20Z")

</div>

How can I get a _randomly initialized_ RNG that is “independent” of `Base.Random.GLOBAL_RNG` (in the sense that I can use them in different threads in parallel)?

I thought of `MersenneTwister()`, but that is deprecated without an argument.

Is

```julia
srand(copy(Base.Random.GLOBAL_RNG))

```

the way to do it?

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [November 25, 2017, 8:06pm UTC](https://discourse.julialang.org/t/how-to-get-a-new-independent-randomly-initialized-rng/7310/2 "2017-11-25T20:06:58Z")

</div>

> [@Tamas\_Papp](#):
>
> I thought of MersenneTwister(), but that is deprecated without an argument.

It’s un-deprecated in 0.7. If you are on 0.6, an equivalent way is simply `srand(MersenneTwister(0))`. Equivalently, you can generate a random seed for `MersenneTwister` with e.g. `seed = rand(RandomDevice(), UInt32, 4); rng = MersenneTwister(seed)`.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/julialang/original/3X/1/2/12829a7ba92b924d4ce81099cbf99785bee9b405.png) [@system](https://discourse.julialang.org/u/system)\
**Post date:** [November 28, 2017, 7:48pm UTC](https://discourse.julialang.org/t/how-to-get-a-new-independent-randomly-initialized-rng/7310/3 "2017-11-28T19:48:25Z")

</div>

Closed on November 28, 2017, 7:48pm UTC

This topic was automatically closed after 3 days. New replies are no longer allowed.
