# Understanding stepsize in stochastic simulations

22 views

### Sebastián Espinel Ríos

Feb 20, 2024, 10:47:27 AMFeb 20
to COPASI User Forum
Hi,

I have a question about the output of a stochastic simulation (direct method). If I set the stepsize to say 0.5 s while running a stochastic simulation in Copasi, I will basically force the output results to be equidistant in time (every 0.5 s), which is convenient for statistical analysis.

Does that mean that the stochastic simulation also works with equidistant time steps? I suspect not, since that goes against the intrinsic idea of Gillespie´s algorithm where the time step is also random. Then, how is the stepsize working here and how is influencing the simulation (if at all)?  Or is it that we basically "read" the state of the system every 0.5 s (stepsize), but the reactions are actually happening at random delta times.

This is my current configuration:
result = run_time_course(duration = t_f, automatic = False, method = "directMethod", max_steps = 1000000, seed=1234,  use_seed =  True, stepsize= 0.5, use_numbers=True)

Best,
Sebastián

### Pedro Mendes

Feb 20, 2024, 10:56:30 AMFeb 20
Hi Sebastián,

your intuition is right. The "stepsize" is really only for output, i.e.
it only governs how often to collect states of the system, either for
reports or for plots. The simulation happens at the times that the
Gillespie algorithm determines (by sampling from the appropriate
distribution). If you want to have output of all the reaction events,
just click "auto" instead of setting a stepsize. COPASI will then output
the state of the system at each reaction event. Be careful if you do
this as there can be a very large number of events (ie tiny stepsize)

By the way, the same applies to the ODE solvers. The interval sizes are
only for output, as the algorithms decide the stepsize themselves. If
you click "auto" then you get the actual steps of the integrator.

Hope this helps
Pedro
> --
> You received this message because you are subscribed to the Google
> Groups "COPASI User Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send