Stats.Weighted Mean<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.4
C#
The mean of the variable weighted by weights.
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
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
DoubleThe 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
Argument | values is null. |
Dimension | The length of weights does not equal the number of observations of the variable. |