alanderos91 / BioSimulator.jl

A stochastic simulation framework in Julia.
https://alanderos91.github.io/BioSimulator.jl/stable/
Other
47 stars 7 forks source link

Very regular pattern of the variance profile #22

Closed skycolt closed 4 years ago

skycolt commented 4 years ago
Screen Shot 2019-10-03 at 3 59 28 PM

Hello,

I am doing simulation with simple simulation and plot command. result = simulate(model, Direct(), time = 10000.0, epochs = 50, trials = 1000) plot(result; plot_type = :meantrajectory)

I got the result that you can see from the attached picture. There are very regular patterns for the variance of all the variables. if you look carefully, similar pattern also exist for your example. as a stochastic simulation, I don't expect the variance to change so regularly. Do you think it a problem? Is there something I can do like to choose a better random number generator?

Thanks

skycolt commented 4 years ago

I get the data from result file and drew the figure myself. It now looks like this:

Screen Shot 2019-10-03 at 5 08 49 PM

I think you may have something wrong in your plot function, maybe on calculating the error.

alanderos91 commented 4 years ago

I have not seriously considered whether the built-in RNG is appropriate for stochastic simulation in general. Adding other RNG types is straightforward, but I have not introduced it yet (I've been working on a rather big change offline).

That being said, I don't think the RNG is causing the regular pattern. I have come across this myself but never been able to reproduce it (but it happens often enough). I suspected it is related to the way the "regular paths" are constructed. Measurements over regular intervals are binned; see here.

How did you simulate the data you plotted in your second figure? If you used the "fixed interval" option then it isolates the problem to the plotting recipe here.

skycolt commented 4 years ago

Now I don't think it's the problem of RNG but that's definitely an option great to have. I used the following code to generate the cure for one species. It looks like the problem is somewhere post simulation.

result = simulate(model, OptimizedDirect(), time = 10000.0, epochs = 200, trials = 2000) data=result.simulation_data for i=1:2000 s1[i,:]=data[i].xdata[1,:] end plot(1:201,mean(s1,dims=1)',yerr=std(s1,dims=1)')