Sunday, 8 June 2014
Running statistics using RunningStats (how to run on Python using SWIG and Distutils)
There is a more accurate method for calculating focal statistics than usually implemented in numerical packages. This is documented here and the C++ code is download from here
The SWIG setup file is simple:
which you run using:
The Distutils setup script is:
compile using "python setup.py install"
Then in python, a simple implementation of calculating the global stats from an array would be something like:
To show the convergence of locals means on the global mean, you might use the RunningStats class in the following way:
Finally, to compute running averages on the array you might use something like the following, where the function to window the data efficiently was downloaded from here
Obviously, as well as the mean, the above could be used for variance, standard deviation, kurtosis and skewness.