Sensor Calibration Least Squares
Fit a two-point linear calibration to raw sensor readings using least squares, and report the residual so a bad sensor can be rejected.
Constraints
- Inputs are raw readings and reference values of equal length.
- Return slope, offset and the RMS residual.
- Fewer than 2 points must raise ValueError.
- A degenerate fit where all raw values are equal must raise ValueError.
- Implement the normal equations directly; no numpy.polyfit.
1def calibrate(raw, reference):2 # TODO3 return {}