Generates a reporter function that takes the model object and returns a summary statistic over all the values of an agent property.
Parameters
key — str, required
The name of the agent property the generated function should summarize.
prim — str, optional
The agent primitive whose properties should be gathered. A value of
None
will select the first primitive in order, usually'agent'
unless that primitive has been removed or reordered.Default value: None
breed — str, optional
Whether to limit the statistic to a particular breed.
Default value: None
good — str, optional
The
good
argument can be used to specify a dict key if the property is a dict of values rather than a numeric value itself. For example, becauseagent.stocks
is a dict, the good name would need to be specified here in order to return inventories of a specific good.Default value: None
stat — str, optional
The summary statistic to be reported. Possible values are
'mean'
,'sum'
,'gmean'
(for geometric mean),'std'
(for standard deviation), or'percentile-nn'
, where nn is a number from 0-100. (Note this last option would be to record only the percentile statistic. Percentiles can be drawn alongside a main statistic using the following argument)Default value: 'mean'
percentiles — list[int], optional
Augments the reporter with percentiles corresponding to the list values. If drawn using
TimeSeriesPlot.addSeries
, the percentiles will show as lighter and dotted lines on the same plot alongside the main series, or as error bars if drawn usingChart.addBar
and if there are two list items. The percentiles will also be recorded as new columns in the data with the same name, postfixed by-nn-pctile
.Default value: []
std — float, optional
Augments the reporter with two additional reporters for the mean ± some multiple of the standard deviation. If drawn using
TimeSeriesPlot.addSeries
, the bounds will be drawn as lighter and dotted lines on the same plot alongside the main series, or as error bars if drawn usingChart.addBar
.Default value: None
Return Value — func(Model)|tuple(func(model),list[func])
A function that takes the model object and returns a numeric value, or a tuple with the first element being such a function, and the second being a list of subplot functions (e.g. for percentiles or ± standard deviations).
charwick
Mar 23, 2020 at 3:17This example generates a reporter for aggregate expected consumption and average target real balances for each breed, and passes it to data.addReporter().
This example generates reporters for average inventories of each registered good, across all breeds of the
'store'
primitive, along with 25th and 75th percentiles that will draw along with it if the registered reporter is passed tomodel.addSeries()
.charwick
Mar 23, 2020 at 3:25Functions generated by
agentReporter
do not have to be used exclusively withdata.addReporter()
. In fact, they can be used anywhere a live value for an aggregate statistic is needed. Note however that iterating over many agents multiple times each period is computationally expensive, so it may be wise to pull the already-aggregated variable fromdata.getLast()
instead if the reporter is being collected already, and if a live value is not needed.This example creates a property of the model object that uses an agent reporter to tally up the quantity of the monetary good existing in the model economy. Note that a reporter always takes one argument, the model object, which is passed to the generated function in order to return the value of the reporter rather than the reporter function.