Stats.WeightedMean<T> Method

Returns the mean of the variable with observations weighted by the specified vector.

Definition

Namespace: Numerics.NET.Statistics
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.2
C#
public static double WeightedMean<T>(
	this Vector<T> values,
	Vector<T> weights
)

Parameters

values  Vector<T>
A vector containing the data.
weights  Vector<T>
A vector containing the weights. May be null.

Type Parameters

T

Return Value

Double
The mean of the variable weighted by weights.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. 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

If weights is null, the unweighted mean is returned.

Exceptions

ArgumentNullException

values is null.

DimensionMismatchException

The length of weights does not equal the number of observations of the variable.

See Also