def __init__(self, name, initial_size=0, sim_rep=0, collect_stat=True, ave_method='step', warm_up_period=0): """ :param name: name of this sample path :param initial_size: value of the sample path at simulation time 0 :param sim_rep: (int) simulation replication of this sample path :param collect_stat: set to True to collect statistics on average, max, min, stDev, etc for this sample path :param ave_method: to calculate the area under the curve, 'step' assumes that changes occurred at the time where observations are recorded, 'linear' assumes uses trapezoid approach to calculate the area under the curve :param warm_up_period: warm up period (observations before this time will not be used to calculate statistics) """ _SamplePath.__init__(self, name=name, sim_rep=sim_rep, collect_stat=collect_stat, warm_up_period=warm_up_period) self.currentSize = initial_size # current size of the sample path self._times = [0] self._values = [initial_size] # statistics on this prevalence sample path if collect_stat: self.stat = Stat.ContinuousTimeStat(name=name, initial_time=warm_up_period, ave_method=ave_method)
def mytest_continuous_time(times, observations): # define a continuous-time statistics continuous_stat = Stat.ContinuousTimeStat(initial_time=0, name='Test continuous-time statistics') for obs in range(0, len(times)): # find the increment inc = 0 if obs == 0: inc = observations[obs] else: inc = observations[obs] - observations[obs - 1] continuous_stat.record(times[obs], inc) print('Testing continuous-time statistics:') print_results(continuous_stat)