# Why does the plot of EnsembleProblem differ from the original ODEProblem?

**URL:** <https://discourse.julialang.org/t/why-does-the-plot-of-ensembleproblem-differ-from-the-original-odeproblem/118415>\
**Category:** Numerics\
**Tags:** diffeq, monte-carlo, sciml, plot, ordinarydiffeq\
**Created:** [August 20, 2024, 1:14pm UTC](https://discourse.julialang.org/t/why-does-the-plot-of-ensembleproblem-differ-from-the-original-odeproblem/118415 "2024-08-20T13:14:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![homocomputeris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/homocomputeris/32/8933_2.png) [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Post date:** [August 20, 2024, 1:14pm UTC](https://discourse.julialang.org/t/why-does-the-plot-of-ensembleproblem-differ-from-the-original-odeproblem/118415/1 "2024-08-20T13:14:44Z")

</div>

I assume that if I don’t change the problem in EnsembleProblem, the EnsembleSummary should produce the same plot as the original ODEProblem solution.

Simple example:

```julia
module test

using Plots, StatsPlots
using LinearAlgebra
using OrdinaryDiffEq
using SciMLExpectations
using Distributions

function f(u, p, t)
    return [
        u[2],
        -1 * u[1] + u[3] * (1 - u[1]^2) * u[2],
        0
    ]
end

tspan = (0.0, 2000.0)
u0 = [2.0, 0, 1000]

p = nothing
ref = ODEProblem(f, u0, tspan, p)
refsol = solve(ref, AutoTsit5(Rosenbrock23()))
display(plot(refsol, idxs=[1, 2], title="Van der Pol"))

prob_func(prob, i, repeat) = remake(prob,
    p=nothing)
ensemble_prob = EnsembleProblem(ref, prob_func=prob_func)

ensemblesol = solve(ensemble_prob,
    AutoTsit5(Rosenbrock23()),
    EnsembleThreads(),
    trajectories=3)

summ = EnsembleSummary(ensemblesol)
display(plot(summ, idxs=[1, 2], title="Ensemble"))

# there is no difference
for uu in ensemblesol.u
    display(maximum(norm.(uu.u - refsol.u)))
end

end

```

The last loop confirms that the solutions are the same:

```julia
0.0
0.0
0.0

```

However, the plots are different:  
 ![1](https://global.discourse-cdn.com/julialang/original/3X/0/7/07117c2b55cb7252ac58f4eaf9bc9c52e233b8df.png)  
 ![2](https://global.discourse-cdn.com/julialang/original/3X/b/b/bbd50e31c84960f92b8df096b64426168aa559b6.png)

What am I missing?

---

<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:** [August 27, 2024, 2:39pm UTC](https://discourse.julialang.org/t/why-does-the-plot-of-ensembleproblem-differ-from-the-original-odeproblem/118415/2 "2024-08-27T14:39:53Z")

</div>

What about with safetycopy on?

---

<div class="post-metadata">

**Author:** ![homocomputeris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/homocomputeris/32/8933_2.png) [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Post date:** [August 29, 2024, 5:59pm UTC](https://discourse.julialang.org/t/why-does-the-plot-of-ensembleproblem-differ-from-the-original-odeproblem/118415/3 "2024-08-29T17:59:44Z")

</div>

> [@ChrisRackauckas](#):
>
> safetycopy

Same.
