Home»Documentation»Reference»Extreme.DataAnalysis»VectorExtensions Class»Methods»WeightedMovingAverage Method Overloads»WeightedMovingAverage Method (Vector(Double), Double[], Int32)

## VectorExtensions | Extreme Optimization Numerical Libraries for .NET Professional |

**Namespace:**Extreme.DataAnalysis

**Assembly:**Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.1

public static Vector<double> WeightedMovingAverage( this Vector<double> vector, double[] weights, int currentWeightIndex )

#### Parameters

- vector
- Type: Extreme.Mathematics
AddLanguageSpecificTextSet("LST842A06D4_5?cs=.|vb=.|cpp=::|nu=.|fs=."); VectorAddLanguageSpecificTextSet("LST842A06D4_6?cs=<|vb=(Of |cpp=<|fs=<'|nu=("); DoubleAddLanguageSpecificTextSet("LST842A06D4_7?cs=>|vb=)|cpp=>|fs=>|nu=)");

The vector to transform. - weights
- Type:
AddLanguageSpecificTextSet("LST842A06D4_8?cpp=array<"); SystemAddLanguageSpecificTextSet("LST842A06D4_9?cs=.|vb=.|cpp=::|nu=.|fs=."); DoubleAddLanguageSpecificTextSet("LST842A06D4_10?cpp=>|vb=()|nu=[]");

A Double array containing the weights. - currentWeightIndex
- Type: System
AddLanguageSpecificTextSet("LST842A06D4_11?cs=.|vb=.|cpp=::|nu=.|fs=."); Int32

An integer specifying the index in weights that corresponds to the current observation.

#### Return Value

Type: VectorA vector.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type VectorException | Condition |
---|---|

ArgumentNullException | weights is |

ArgumentOutOfRangeException | currentWeightIndex is less than zero or greater than or equal to the length of weights. |

InsufficientDataException |
The length of the vector is less than the length of weights.
-or- The length of weights is zero. |

The weights are applied backwards. If currentWeightIndex is zero, then the first component of weights gives the weight for the current observation, the second component gives the weight for the previous observation, and so on.

The new vector gets the name WMA<n>(<name>), where <name> is the name of the original vector and <n> . is the length of weights.

#### Reference

Copyright © 2004-2023,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.