daily_age_stats#

class daily_age_stats(states=None, edges=None, **kwargs)[source]#

Bases: Analyzer

Calculate daily counts by age, saving for each day of the simulation. Can plot either time series by age or a histogram over all time.

Parameters:
  • states (list) – which states of people to record (default: [‘diagnoses’, ‘deaths’, ‘tests’, ‘severe’])

  • edges (list) – edges of age bins to use (default: 10 year bins from 0 to 100)

  • kwargs (dict) – passed to Analyzer()

Examples:

sim = cv.Sim(analyzers=cv.daily_age_stats())
sim = cv.Sim(pars, analyzers=daily_age)
sim.run()
daily_age = sim.get_analyzer()
daily_age.plot()
daily_age.plot(total=True)

Methods

to_df()[source]#

Create dataframe totals for each day

to_total_df()[source]#

Create dataframe totals across days

plot(total=False, do_show=None, fig_args=None, axis_args=None, plot_args=None, dateformat=None, width=0.8, color='#F8A493', **kwargs)[source]#

Plot the results.

Parameters:
  • total (bool) – whether to plot the total histograms rather than time series

  • do_show (bool) – whether to show the plot

  • fig_args (dict) – passed to pl.figure()

  • axis_args (dict) – passed to pl.subplots_adjust()

  • plot_args (dict) – passed to pl.plot()

  • dateformat (str) – the format to use for the x-axes (only used for time series)

  • width (float) – width of bars (only used for histograms)

  • color (hex/rgb) – the color of the bars (only used for histograms)

  • kwargs (dict) – passed to cv.options.with_style()