# How to fix time intervals to store data in a stochastic simulation (continous time markov chain)

I am using FORTRAN to implement Gillespie's stochastic simulation algorithm. I would be running many simulations in parallel (both parallel instances with different seed and parallel functions); if I have to store every time interval then a lot of memory would be consumed. So I thought I can have some fixed number of time points where the data would be saved (Allocate space beforehand either dynamically or statically).

How do I decide the size of the time intervals? Should the intervals have a fixed size or it should be based on local dynamics(some regions would have more dynamics)? Is there any way to predict that based on the deterministic function without actually running a deterministic simulation?

I have this vague idea that the tau-leap formula can be used to predict time intervals where n number of a major reaction would occur. But this still doesn't help me predict the number of steps beforehand.

• Ran into a similar issue doing some monte carlo sampling. I would look into working with hdf files. The way I solved it was only allocating room for a 10000 element array on each processor and at the end of simulating through that array, write out your simulations to the hdf file (organized by processor) and then start filling the array from the beginning again. Feb 15 '15 at 14:52
• @cc7768 you mean to say store the data for a simulation run (for some fixed sampling points) and then rerun the simulation to get data between these points? This would actually take a lot of time. We can obtain slopes of the function using a deterministic simulation which can be used to calculate time intervals. This seems less time consuming to me. The integration at this moment takes about 1s in MATLAB. Thanks for suggesting HDF, I'll give it a try. Need to read about it first. Feb 16 '15 at 12:43
• My comment is more directed to dealing with the memory issue and won't help wrt computation of optimal time intervals etc... I'm saying hdf is a good format for storing large amounts of data such as simulations that require many periods/iterations. Feb 17 '15 at 7:05