Simple descriptive statistics.
If you want to add your own statistic, subclass Keeper and implement Keeper.__init__(), Keeper.get(), and Keeper.update(). Then your statistic will be easy to plug in to citystats.compute_route_stats().
Tracks the sample size (number of observations) of a variable.
Parameter: | seq (list(numeric)) – If you pass a sequence to the constructor, the SampleSize will be initialized with its length. |
---|
Returns: | The current sample size. |
---|---|
Return type: | int |
Tracks the average of a variable.
Parameter: | seq (list(numeric)) – If you pass a sequence or iterable to the constructor, this object will be initialized with its average. |
---|
Returns: | The current average. |
---|---|
Return type: | float |
Adds value to this average keeper.
Parameter: | value (numeric) – Value to be added to this keeper. |
---|
Tracks the sample (N-1) variance of a variable.
Parameter: | seq (list(numeric)) – If you pass a sequence or iterable to the constructor, this object will be initialized with its variance. |
---|
Returns: | The current sample (N - 1) variance. |
---|---|
Return type: | float |
Adds value to this keeper.
Parameter: | value (numeric) – Value to be added to this keeper. |
---|
Tracks the sample (N-1) standard deviation of a variable.
Parameter: | seq (list(numeric)) – If you pass a sequence or iterable to the constructor, this object will be initialized with its standard deviation. |
---|
Returns: | The current sample (N - 1) variance. |
---|---|
Return type: | float |
Adds value to this keeper.
Parameter: | value (numeric) – Value to be added to this keeper. |
---|
Abstract base class for statistics keepers.
Defines two methods: update(), which adds one observation to the Keeper; and get(), which returns the current value of the statistic. Also defines __init__(), which can optionally take a sequence to initialize the Keeper.
Incidentally, don’t call super() in any derived classes.
Initializes a new Keeper.
Parameter: | seq (list(numeric)) – If you pass a sequence to the constructor, the Keeper will be initialized as if update() had been called with each value in seq. |
---|
Returns: | the current value of the statistic stored in this Keeper. |
---|---|
Return type: | numeric |
Updates the statistic stored in this Keeper with value.
Parameter: | value (numeric) – Observation to add to this Keeper. |
---|