Working on #88 I noticed it might have opened the possibility to make the simulation methods more general and maybe simpler.
The mark distributions have their own sample_mark(md::MarkDistribution, t, h::History) method. The idea is to have a sample_time(pp::PointProcess, h::History) method as well (method names to be defined).
sample_time would return the next event after history h or, if the next event time would fall beyond h.tmax, return nothing. With this, we could define
function simulate(pp::PointProcess, tmin, tmax)
h = History(tmin, tmax) # Empty history
t = sample_time(pp, h)
while t
m = sample_mark(pp.mark_dist, t, h) # Should probably be implemented for point processes, like `sample_mark(pp, t, h)`
push!(h, t, m)
t = sample_time(pp, h)
end
return h
end
The advantage being that this works for any point process and any mark distribution, no matter if the mark distribution and event times are dependent.
Additionally, sample_time could have a fallback, which would be basically the algorithm from simulate_ogata, but instead of simulating the whole process, it just simulates the next event.
Another possibility would be to have a method inverse_integrated_ground_intensity (or something similar, but not that long) to implement the fallback for sample_time. This is probably more efficient than sampling multiple times until one can be kept, and since we need an additional method anyway (ground_intensity_bound or inverse_integrated_ground_intensity), might as well use this.
Working on #88 I noticed it might have opened the possibility to make the simulation methods more general and maybe simpler.
The mark distributions have their own
sample_mark(md::MarkDistribution, t, h::History)method. The idea is to have asample_time(pp::PointProcess, h::History)method as well (method names to be defined).sample_timewould return the next event after historyhor, if the next event time would fall beyondh.tmax, returnnothing. With this, we could defineThe advantage being that this works for any point process and any mark distribution, no matter if the mark distribution and event times are dependent.
Additionally,
sample_timecould have a fallback, which would be basically the algorithm fromsimulate_ogata, but instead of simulating the whole process, it just simulates the next event.Another possibility would be to have a method
inverse_integrated_ground_intensity(or something similar, but not that long) to implement the fallback forsample_time. This is probably more efficient than sampling multiple times until one can be kept, and since we need an additional method anyway (ground_intensity_boundorinverse_integrated_ground_intensity), might as well use this.