using scipy signal and numpy correlate to calculate some time series statistics
see also scikits.timeseries (movstat is partially inspired by it) (added 2009-08-29: timeseries moving stats are in c, autocorrelation similar to here I thought I saw moving stats somewhere in python, maybe not)
TODO:
moving statistics * filters don’t handle boundary conditions nicely (correctly ?)
e.g. minimum order filter uses 0 for out of bounds value -> append and prepend with last resp. first value
Note: Equivalence for 1D signals >>> np.all(signal.correlate(x,[1,1,1],’valid’)==np.correlate(x,[1,1,1])) True >>> np.all(ndimage.filters.correlate(x,[1,1,1], origin = -1)[:-3+1]==np.correlate(x,[1,1,1])) True
# multidimensional, but, it looks like it uses common filter across time series, no VAR ndimage.filters.correlate(np.vstack([x,x]),np.array([[1,1,1],[0,0,0]]), origin = 1) ndimage.filters.correlate(x,[1,1,1],origin = 1)) ndimage.filters.correlate(np.vstack([x,x]),np.array([[0.5,0.5,0.5],[0.5,0.5,0.5]]), origin = 1)
>>> np.all(ndimage.filters.correlate(np.vstack([x,x]),np.array([[1,1,1],[0,0,0]]), origin = 1)[0]==ndimage.filters.correlate(x,[1,1,1],origin = 1))
True
>>> np.all(ndimage.filters.correlate(np.vstack([x,x]),np.array([[0.5,0.5,0.5],[0.5,0.5,0.5]]), origin = 1)[0]==ndimage.filters.correlate(x,[1,1,1],origin = 1))
update: 2009-09-06: cosmetic changes, rearrangements
Functions
acf(x[, unbiased]) | autocorrelation function for 1d |
acovf(x[, unbiased, demean]) | autocovariance for 1D |
assert_array_almost_equal(x, y[, decimal, ...]) | Raise an assertion if two objects are not equal up to desired precision. |
assert_array_equal(x, y[, err_msg, verbose]) | Raise an assertion if two array_like objects are not equal. |
ccf(x, y[, unbiased]) | cross-correlation function for 1d |
ccovf(x, y[, unbiased, demean]) | crosscovariance for 1D |
check_movorder() | graphical test for movorder |
expandarr(x, k) | |
movmean(x[, windowsize, lag]) | moving window mean |
movmoment(x, k[, windowsize, lag]) | non-central moment |
movorder(x[, order, windsize, lag]) | moving order statistics |
movvar(x[, windowsize, lag]) | moving window variance |
pacf_ols(x[, maxlag]) | Partial autocorrelation estimated with non-recursive OLS |
pacf_yw(x[, maxlag, method]) | Partial autocorrelation estimated with non-recursive yule_walker |