All problems

Weighted Calibration Offset Is Divided by Sample Count

Level 2 · node · Correctness · Weighted calibration error uses sample count as denominator

Scenario

A fictional precision instrument calibration service computes a device-specific offset from reference and observed values, using confidence weights. The output looks reasonable for some simple samples, but differing weights cause the reported offset to depart from the weighted mean. Trace the calibration data through the repository, service, and controller.

Requirements

Compute the calibration offset by dividing the sum of weighted observed-minus-reference errors by the sum of weights. Preserve sample insertion, per-device isolation, empty-device behavior, and rejection of invalid numbers or weights. Do not use external network calls or system time.

Acceptance criteria

  • A single sample's offset equals observed minus reference.
  • Equal-weight samples produce the arithmetic mean of their errors.
  • Unequal weights use the sum of weighted errors divided by the total weight.
  • A higher-weight sample has proportionally greater influence on the offset.
  • Calibration records and summaries remain isolated per device.
  • An empty device returns count zero and offset zero.
  • Invalid samples are rejected without changing existing summaries.