print(path1.stat.get_mean())

# second sample path with initial size = 1
path2 = Path.IncidenceSamplePath('Path 2', delta_t=1, sim_rep=1)
# record the observations
path2.record_increment(0.5, 4)
path2.record_increment(1.8, 2)
path2.record_increment(5.5, 1)
path2.close(6)
# stats
print(path2.stat.get_mean())

# plot path 1 only
Path.plot_sample_path(
    sample_path=path1,
    title='Plotting a single sample path',
    x_label='Time Period',
    y_label='observed value',
    legend='Path 1',
    color_code='r',
    connect='line')

Path.plot_sample_path(
    sample_path=path2,
    title='Plotting a single sample path',
    x_label='Time Period',
    y_label='observed value',
    legend='Path 2',
    color_code='r',
    connect='line')
Beispiel #2
0
import SimPy.Plots.Histogram as Hist
import SimPy.Plots.SamplePaths as Path

# selected therapy
therapy = P.Therapies.COMBO

# create a cohort
myCohort = Cls.Cohort(id=1,
                      pop_size=D.POP_SIZE,
                      parameters=P.Parameters(therapy=therapy))

# simulate the cohort over the specified time steps
myCohort.simulate(sim_length=D.SIM_LENGTH)

# plot the sample path (survival curve)
Path.plot_sample_path(sample_path=myCohort.cohortOutcomes.nLivingPatients,
                      title='Survival Curve',
                      x_label='Time-Step (Year)',
                      y_label='Number Survived')

# plot the histogram of survival times
Hist.plot_histogram(data=myCohort.cohortOutcomes.survivalTimes,
                    title='Histogram of Patient Survival Time',
                    x_label='Survival Time (Year)',
                    y_label='Count',
                    bin_width=1)

# print the outcomes of this simulated cohort
Support.print_outcomes(sim_outcomes=myCohort.cohortOutcomes,
                       therapy_name=therapy)
Beispiel #3
0
                                       increments=[2, -1, 0],
                                       sim_rep=1)
path4 = Path.PrevalencePathBatchUpdate('Path 4',
                                       0,
                                       times_of_changes=[0.5, 4, 4.5],
                                       increments=[2.5, 1, 1],
                                       sim_rep=1)

# stats
print(path1.stat.get_mean())

# plot path 1 only
Path.plot_sample_path(sample_path=path1,
                      title='Plotting a single sample path',
                      x_label='time',
                      y_label='observed value',
                      legend='Path 1',
                      color_code='r',
                      connect='step')

# plot path 3 only
Path.plot_sample_path(
    sample_path=path3,
    title='Plotting a single sample path that is updated in batch',
    x_label='time',
    y_label='observed value',
    legend='Path 3',
    color_code='r')

# plot both paths
Path.plot_sample_paths(sample_paths=[path1, path2],