Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add centering at median for the EnsembleSummary #543

Open
jlperla opened this issue Jul 3, 2020 · 1 comment
Open

Add centering at median for the EnsembleSummary #543

jlperla opened this issue Jul 3, 2020 · 1 comment

Comments

@jlperla
Copy link

jlperla commented Jul 3, 2020

The following code seems to work,, though I would want to make sure you like the naming and approach before adding tests/etc.

import DiffEqBase: EnsembleSummary
function DiffEqBase.EnsembleSummary(sim::DiffEqBase.AbstractEnsembleSolution{T,N},
                         t=sim[1].t;quantiles=[0.05,0.95], centermedian = false) where {T,N}
  if typeof(sim[1]) <: DiffEqBase.DESolution
    m,v = timeseries_point_meanvar(sim,t)
    med = timeseries_point_median(sim,t)
    qlow = timeseries_point_quantile(sim,quantiles[1],t)
    qhigh = timeseries_point_quantile(sim,quantiles[2],t)
  else
    m,v = timeseries_steps_meanvar(sim)
    med = timeseries_steps_median(sim)
    qlow = timeseries_steps_quantile(sim,quantiles[1])
    qhigh = timeseries_steps_quantile(sim,quantiles[2])
  end

  trajectories = length(sim)
  DiffEqBase.EnsembleSummary{T,N,typeof(t),typeof(m),typeof(v),typeof(qlow),typeof(qhigh)}(t,centermedian ? med : m,v,qlow,qhigh,trajectories,sim.elapsedTime,sim.converged)
end

As another interfacepoint, the quantiles argument takes in an array, but only works ones of length two. Perhaps it should be a tuple to avoid giving the impression that you can pass in more than 2.

@ChrisRackauckas
Copy link
Member

Yeah, that seems like an agreeable change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants