 # Weighted Moving Average | Standard | Formulas | Analyze Data | Documentation ## Application to measuring computer performanceEdit

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.

Sn=α(tn−tn−1)×Yn (1−α(tn−tn−1))×Sn−1.{displaystyle S_{n}=alpha (t_{n}-t_{n-1})times Y_{n} (1-alpha (t_{n}-t_{n-1}))times S_{n-1}.}

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

α(tn−tn−1)=1−exp⁡(−tn−tn−1W×60){displaystyle alpha (t_{n}-t_{n-1})=1-exp left({-{{t_{n}-t_{n-1}} over {Wtimes 60}}}right)}

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).

Sn=(1−exp⁡(−tn−tn−1W×60))×Yn exp⁡(−tn−tn−1W×60)×Sn−1{displaystyle S_{n}=left(1-exp left(-{{t_{n}-t_{n-1}} over {Wtimes 60}}right)right)times Y_{n} exp left(-{{t_{n}-t_{n-1}} over {Wtimes 60}}right)times S_{n-1}}

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

Ln=(1−exp⁡(−515×60))×Qn e−515×60×Ln−1=(1−exp⁡(−1180))×Qn e−1/180×Ln−1=Qn e−1/180×(Ln−1−Qn){displaystyle {begin{aligned}L_{n}{amp}amp;=left(1-exp left({-{5 over {15times 60}}}right)right)times Q_{n} e^{-{5 over {15times 60}}}times L_{n-1}\[6pt]{amp}amp;=left(1-exp left({-{1 over {180}}}right)right)times Q_{n} e^{-1/180}times L_{n-1}\[6pt]{amp}amp;=Q_{n} e^{-1/180}times (L_{n-1}-Q_{n})end{aligned}}}

## Calculation

The most recent data is more heavily weighted, and contributes more to the final WMA value.

The weighting factor used to calculate the WMA is determined by the period selected for the indicator. For example, a 5 period WMA would be calculated as follows:

WMA = (P1 * 5) (P2 * 4) (P3 * 3) (P4 * 2) (P5 * 1) / (5 4 3 2 1)

Where:

P1 = current price

P2 = price one bar ago, etc…

## Cumulative moving average — discreteEdit

According to probability distributions we have to distinguish between a

• discrete (probability mass function pv{displaystyle p_{v}} ) and
• continuous (probability density function pv{displaystyle p_{v}} )

moving average. The terminology refers to probability distributions and the semantics of probability mass/density function describes the distrubtion of weights around the value <math xmlns="http://www.w3.

org/1998/Math/MathML» alttext=»{displaystyle vin V}»>v∈V{displaystyle vin V}<span class="lazy-image-placeholder" data-src="https://wikimedia.

org/api/rest_v1/media/math/render/svg/99886ebbde63daa0224fb9bf56fa11b3c8a6f4fb» data-alt=»{displaystyle vin V}» data-class=»mwe-math-fallback-image-inline»> . In the discrete setting the <math xmlns="http://www.w3.

org/1998/Math/MathML» alttext=»{displaystyle p_{v}(x)=0.2}»>pv(x)=0.

2{displaystyle p_{v}(x)=0.2}<span class="lazy-image-placeholder" data-src="https://wikimedia.org/api/rest_v1/media/math/render/svg/9515b34daa09fc112ac502b05449272f1a037946" data-alt="{displaystyle p_{v}(x)=0.

2}» data-class=»mwe-math-fallback-image-inline»>  means that x{displaystyle x}<span class="lazy-image-placeholder" data-src="https://wikimedia.

org/api/rest_v1/media/math/render/svg/87f9e315fd7e2ba406057a97300593c4802b53e4″ data-alt=»x» data-class=»mwe-math-fallback-image-inline»>  has a 20% impact on the moving average <math xmlns="http://www.w3.

org/1998/Math/MathML» alttext=»{displaystyle MA(v)}»>MA(v){displaystyle MA(v)}<span class="lazy-image-placeholder" data-src="https://wikimedia.

org/api/rest_v1/media/math/render/svg/19919dae041322485c2b773284f6bc707069b3a8″ data-alt=»{displaystyle MA(v)}» data-class=»mwe-math-fallback-image-inline»>  for <math xmlns="http://www.w3.

org/1998/Math/MathML» alttext=»{displaystyle v}»>v{displaystyle v}<span class="lazy-image-placeholder" data-src="https://wikimedia.

class=» lazy-image-placeholder»=»» data-src=»»>

Понравилась статья? Поделиться с друзьями: 