# VectorExtensions.MovingAverage Method

## Definition

Namespace: Extreme.DataAnalysis
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

 MovingAverage(Vector, Int32) Returns a vector whose observations are the simple moving average of the observations of the vector. MovingAverage(Vector, Int32, Boolean) Returns a vector whose observations are the simple moving average of the observations of the vector.

## VectorExtensions.MovingAverage(Vector<Double>, Int32)

Returns a vector whose observations are the simple moving average of the observations of the vector.
C#
``````public static Vector<double> MovingAverage(
this Vector<double> vector,
int length
)``````

#### Parameters

vector  Vector<Double>
The vector to transform.
length  Int32
The number of observations to be used in the average.

Vector<Double>
A vector.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

### Remarks

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

### Exceptions

 ArgumentOutOfRangeException length is less than or equal to zero.

## VectorExtensions.MovingAverage(Vector<Double>, Int32, Boolean)

Returns a vector whose observations are the simple moving average of the observations of the vector.
C#
``````public static Vector<double> MovingAverage(
this Vector<double> vector,
int length,
bool allowPartialWindows
)``````

#### Parameters

vector  Vector<Double>
The vector to transform.
length  Int32
The number of observations to be used in the average.
allowPartialWindows  Boolean
Specifies whether averages are computed for windows with missing values.

Vector<Double>
A vector.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

### Remarks

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

### Exceptions

 ArgumentOutOfRangeException length is less than or equal to zero.