Click or drag to resize

NMathFunctionsWeightedMedian(DoubleVector, DoubleVector) Method

Returns the weighted median of an array of data with associated non-negative weights. There must be at least one postive non-zero weight.

Namespace: CenterSpace.NMath.Core
Assembly: NMath (in NMath.dll) Version: 7.4
Syntax
public static double WeightedMedian(
	DoubleVector data,
	DoubleVector weights
)

Parameters

data  DoubleVector
An DoubleVector containing the data.
weights  DoubleVector
An DoubleVector containing the non-negative weights.

Return Value

Double
Exceptions
ExceptionCondition
InvalidArgumentExceptionThe two lengths of the data and weights vectors must be equal.
InvalidArgumentExceptionThere must be at least one postive non-zero weight.
InvalidArgumentExceptionAll weights must be non-negative. At least one negative weight was found.
Remarks
If the lower sum of the weights is equal the weight's midpoint, then the average of the adjacent two datapoints is returned.
See Also