An exponential moving average (EMA), also known as an exponentially weighted moving average (EWMA), is a type of infinite impulse response filter that applies weighting factors which decrease exponentially. The weighting for each older datum decreases exponentially, never reaching zero. The graph at right shows an example of the weight decrease.
The EMA for a series of collected data with a set of dates ,
where is the collected data at time index .
First of all we have to defined a value with , that represents the degree of weighting decrease as a constant smoothing factor between 0 and 1. A lower α discounts older observations faster.
The sum of weights from 0 to the time index is defined by:
The discrete probability mass function is defined by:
The definition above creates the exponential moving average EMA with discrete probability mass function by
The at time index may be calculated recursively:
The coefficient represents the degree of weighting decrease from to . This implements the aging of data from to time index .
the fraction adjusts the denominator for .
the coefficient in the EMA at time index t+1.
Initialization of EMA and Elimination of MA Impact form old data[edit | edit source]
may be initialized in a number of different ways, most commonly by setting to the first collected data at time index 0 as shown above, though other techniques exist, such as starting the calculation of the moving average after the first 4 or 5 observations. Furthermore only a most recent subset of collected data before the time index from the total history of collected date might be used for the .
The discrete probability mass function puts weights on the most recent values of the collected data by:
The limitations to the most recent values of the collected data eliminates the impact of very old data on the resultant moving average completely. By choosing a small old data is less important than recent data and discounts older observations faster, but even the oldest data has a impact on the calculation of at time index .
Tne initialiation of could incorporate something about values prior to the available data, i.e. history before . Tne initialiation could introduce an error in the . In view of this the early results should be regarded as unreliable until the iterations have had time to converge. This is sometimes called a 'spin-up' interval.
Some computer performance metrics, e.g. the average process queue length, or the average CPU utilization, use a form of exponential moving average with the recursive definition.
Here α is defined as a function of time between two readings. An example of a coefficient giving bigger weight to the current reading, and smaller weight to the older readings is
where exp() is the exponential function, time for readings tn is expressed in seconds, and W is the period of time in minutes over which the reading is said to be averaged (the mean lifetime of each reading in the average). Given the above definition of α, the moving average can be expressed as
For example, a 15-minute average L of a process queue length Q, measured every 5 seconds (time difference is 5 seconds), is computed as