# Future.randjump and accumulate?

**URL:** <https://discourse.julialang.org/t/future-randjump-and-accumulate/12298>\
**Category:** General Usage\
**Created:** [July 10, 2018, 2:17pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298 "2018-07-10T14:17:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 10, 2018, 2:17pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298/1 "2018-07-10T14:17:47Z")

</div>

I am getting the following warning with nightly:

```julia
 Warning: `randjump(rng, steps::Integer, len::Integer` is deprecated; use `Future.randjump` and `accumulate` instead

```

The only `Future` I could find is `Distributed.Future`, which is a `DataType`.

The warnings were initially complaining about `randjump(rng, n*(gpt+1))` saying to use `Random.randjump(rng, big(10)^20, n*(gpt+1))` instead which, when I did, gave the above warning. Any clues or pointer to relevant docs?

---

<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:** [July 10, 2018, 2:23pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298/2 "2018-07-10T14:23:03Z")

</div>

My version of `master` appears to have it:

```julia
julia> VERSION
v"0.7.0-beta.214"

julia> using Future

help?> Future.randjump
  randjump(r::MersenneTwister, steps::Integer) -> MersenneTwister

Create an initialized MersenneTwister object, whose state is moved forward (without generating numbers) from r by steps steps. One such step corresponds to the generation of
two Float64 numbers. For each different value of steps, a large polynomial has to be generated internally. One is already pre-computed for steps=big(10)^20.

```

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 10, 2018, 2:29pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298/3 "2018-07-10T14:29:55Z")

</div>

Found it, it was masked by “an existing identifier”, this single most annoying error when forgetting to import some stdlib package and having to restart REPL to find it. Thanks.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 10, 2018, 3:08pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298/4 "2018-07-10T15:08:05Z")

</div>

For the record, this is how I managed to replicate the default behavior of the old `randjump`:

~~oldrandjump(mt, len) = accumulate(Future.randjump, [0; [big(10)^20 for i in 1:len-1]], init = mt)~~

```julia
 oldrandjump(mt, len) = [mt; accumulate(Future.randjump, [big(10)^20 for i in 1:len-1], init = mt)]

```

I am not sure if there is a more obvious way, as this one uses the non-obvious behavior of `accumulate` with a function taking 2 arguments of different types.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [July 10, 2018, 4:19pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298/5 "2018-07-10T16:19:17Z")

</div>

> [@mohamed82008](#):
>
> oldrandjump(mt, len) = accumulate(Future.randjump, [0; [big(10)^20 for i in 1:len-1]], init = mt)

This is not exactly correct. Old `randjump` returned source object as a first element of an array. Your function returns a copy. So actually you should prepend `mt` to a generated sequence without adding `0` element inside.

Actually you have an example of this in the Julia Manual in the last example of this section [https://docs.julialang.org/en/latest/manual/parallel-computing/#The-@threads-Macro-1](https://docs.julialang.org/en/latest/manual/parallel-computing/#The-@threads-Macro-1).

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 10, 2018, 9:09pm UTC](https://discourse.julialang.org/t/future-randjump-and-accumulate/12298/6 "2018-07-10T21:09:36Z")

</div>

Corrected and thanks for the pointer.
