distancematrix.math_tricks

Module Contents

Classes

StreamingStats

Class that tracks a data stream and corresponding mean and standard deviation of a window over this data.

Functions

sliding_mean_std(series, m)

Calculates the sliding mean and standard deviation over the series using a window of size m.

sliding_mean_var(series, m)

Calculates the sliding mean and variance over the series using a window of size m.

distancematrix.math_tricks.sliding_mean_std(series, m)

Calculates the sliding mean and standard deviation over the series using a window of size m. The series should only contain finite values.

Parameters
  • series – 1D numpy array

  • m – sliding window size

Returns

tuple of 2 arrays, each of size (len(series) - m + 1)

distancematrix.math_tricks.sliding_mean_var(series, m)

Calculates the sliding mean and variance over the series using a window of size m. The series should only contain finite values.

Parameters
  • series – 1D numpy array

  • m – sliding window size

Returns

tuple of 2 arrays, each of size (len(series) - m + 1)

class distancematrix.math_tricks.StreamingStats(series, m)

Bases: object

Class that tracks a data stream and corresponding mean and standard deviation of a window over this data.

The data stream has to be updated by the user, after which the mean/std stream will be updated automatically.

This class uses RingBuffers internally, so any old view (data, mean, std) should be considered unreliable after new data was pushed to this class.

append(self, data)
property data(self)
property mean(self)
property std(self)