weightedMean
Calculates a weighted arithmetic mean without requiring weights to sum to 1.
API Reference
Signature
Parameters
Returns
Returns sum(value[i] * weight[i]) / sum(weights) as a new Arith instance.
Throws
- Throws if
valuesorweightsis not an array. - Throws if their lengths differ.
- Throws if any value is non-finite.
- Throws if any weight is non-finite or negative.
- Throws if all weights are zero.
Agent Contract
Agent Notes
- Weights do not need to be normalized.
- Use
weightedMeanfor weighted cost, portfolio weight, or score aggregation. - Do not generate
averageor other aliases.