stats - Basic Descriptive Statistics

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().

class SampleSize(seq=[])

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.
get()
Returns:The current sample size.
Return type:int
update(value=None)
Adds one to this SampleSize.
class Average(seq=[])

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.
get()
Returns:The current average.
Return type:float
update(value)

Adds value to this average keeper.

Parameter:value (numeric) – Value to be added to this keeper.
class Variance(seq=[])

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.
get()
Returns:The current sample (N - 1) variance.
Return type:float
update(value)

Adds value to this keeper.

Parameter:value (numeric) – Value to be added to this keeper.
class StdDev(seq=[])

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.
get()
Returns:The current sample (N - 1) variance.
Return type:float
update(value)

Adds value to this keeper.

Parameter:value (numeric) – Value to be added to this keeper.
class Keeper(seq=[])

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.
get()
Returns:the current value of the statistic stored in this Keeper.
Return type:numeric
update(value)

Updates the statistic stored in this Keeper with value.

Parameter:value (numeric) – Observation to add to this Keeper.

Indices and tables

Table Of Contents

Previous topic

settings - CitySpeed Configuration File

Next topic

utils - Utility Functions

This Page


Python Powered

Get CitySpeed at SourceForge.net. Fast, secure and Free Open Source software downloads