Smoothing Methods

class pycast.methods.simplemovingaverage.SimpleMovingAverage(windowsize=5)[source]

Bases: pycast.methods.basemethod.BaseMethod

Implements the simple moving average.

The SMA algorithm will calculate the average value at time t based on the datapoints between [t - floor(windowsize / 2), t + floor(windowsize / 2)].

Explanation:
http://en.wikipedia.org/wiki/Moving_average
__init__(windowsize=5)[source]

Initializes the SimpleMovingAverage.

Parameters:windowsize (integer) – Size of the SimpleMovingAverages window.
Raise:Raises a ValueError if windowsize is an even or not larger than zero.
_get_parameter_intervals()[source]

Returns the intervals for the methods parameter.

Only parameters with defined intervals can be used for optimization!

Returns:Returns a dictionary containing the parameter intervals, using the parameter name as key, while the value hast the following format: [minValue, maxValue, minIntervalClosed, maxIntervalClosed]
  • minValue
    Minimal value for the parameter
  • maxValue
    Maximal value for the parameter
  • minIntervalClosed
    True, if minValue represents a valid value for the parameter. False otherwise.
  • maxIntervalClosed:
    True, if maxValue represents a valid value for the parameter. False otherwise.
Return type:dictionary
execute(timeSeries)[source]

Creates a new TimeSeries containing the SMA values for the predefined windowsize.

Parameters:timeSeries (TimeSeries) – The TimeSeries used to calculate the simple moving average values.
Returns:TimeSeries object containing the smooth moving average.
Return type:TimeSeries
Raise:Raises a ValueError wif the defined windowsize is larger than the number of elements in timeSeries
Note:This implementation aims to support independent for loop execution.

Previous topic

Base Methods

Next topic

Forecasting Methods

This Page