Method and source check
Last checked:
Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.
Method
Validate complete finite value-weight tokens, require nonnegative weights with a positive total, then divide the sum of weighted products by total weight. Keep input pairs unrounded for contribution products and their sum; round only their displayed values.
weighted mean = Σ(wᵢxᵢ)/Σwᵢ, Σwᵢ>0
Variables and units
- xáµ¢
- value
- wáµ¢
- nonnegative weight
Worked example
For (90,0.3), (85,0.5), (95,0.2), the weighted average is 88.5 and total weight is 1.
Limitations
Result, total weight, and displayed input pairs are rounded to four decimal places. Math.round retains the existing half-tie convention; if scaling for four-place rounding would overflow, the finite representable value is retained. Locale formatting is applied after numerical calculation. Original value and weight rows retain the accepted number precision; derived results use the declared four-place display.
- Weights express relative importance; they need not sum to one.
- This arithmetic mean does not account for uncertainty or correlation among observations.
- Derived values outside the supported finite numerical range are rejected with a localized input-field error.
- Zero individual weights do not affect the result.
- All-zero weights leave the weighted mean undefined and are rejected.
- 10000 with weight 0.000049 and 0 with weight 1 produce displayed weighted mean 0.4900 and contribution total 0.4900; the tiny weight is not rounded before multiplication.