Skip to content

Commit 098bc00

Browse files
committed
feat: add self-heating EIV fit
Add York errors-in-variables regression for multi-observation self-heating fits when both resistance and measurement-current standard uncertainties are supplied. Propagate current uncertainty into the squared-current coordinate, support optional within-observation current/resistance error correlation, and retain York weights, iteration evidence, chi-square diagnostics, and fitted-parameter covariance. Keep finite-range self-heating coefficient evaluation unavailable for EIV fits until direct current-coordinate uncertainty in dissipated power can be propagated without understating uncertainty.
1 parent d1143cf commit 098bc00

7 files changed

Lines changed: 998 additions & 94 deletions

File tree

docs/DESIGN.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,13 +1062,31 @@ parameter covariance. The public uncertainty result records which covariance mod
10621062
was used; its ``residual_variance_ohms_squared`` is present only for the residual-
10631063
scatter ordinary-least-squares path.
10641064

1065-
Neither covariance path is described as propagation of measurement-current
1066-
uncertainty. If uncertainty in current is material, the independent coordinate has
1067-
measurement error and fixed-coordinate least squares is not an adequate model.
1068-
Correlated repeated readings and other common-mode effects likewise require an
1069-
explicit covariance-aware or errors-in-variables treatment rather than being
1070-
inferred from residual scatter or from the supplied marginal resistance
1071-
uncertainties.
1065+
When measurement-current standard uncertainties are supplied together with
1066+
resistance standard uncertainties for every observation, the 3+ observation fitter
1067+
uses York errors-in-variables regression rather than fixed-coordinate least
1068+
squares. The measured current magnitude is the supplied independent quantity, while
1069+
the fitted coordinate is ````; current uncertainty is therefore propagated to the
1070+
fit coordinate by the first-order relation ``u(I²) = 2 I u(I)``. This is an explicit
1071+
local linearization of the coordinate transformation, not a claim that squared
1072+
current is normally distributed for arbitrarily large relative current uncertainty.
1073+
1074+
The York path also accepts an optional correlation coefficient for the current and
1075+
resistance errors of each observation. Since all accepted measurement currents are
1076+
positive, the first-order transformation from ``I`` to ```` has positive
1077+
derivative and preserves that within-observation correlation coefficient. Omitting
1078+
the coefficients records zero within-observation correlation. York weights depend
1079+
on the fitted slope and both coordinate uncertainties, so the solver iterates to a
1080+
converged slope. Its chi-square uses the final combined coordinate-error model, and
1081+
its fitted intercept/slope covariance is obtained from the York adjusted
1082+
coordinates and supplied absolute uncertainties without residual rescaling.
1083+
1084+
This errors-in-variables path still treats separate observations as statistically
1085+
independent. Shared current-source calibration, bridge calibration, environmental
1086+
drift, or other common-mode effects can create cross-observation covariance that a
1087+
per-observation correlation coefficient does not represent. Such covariance must be
1088+
supplied through a separate generalized covariance model rather than inferred from
1089+
replicate scatter, instrument identity, or marginal standard uncertainties.
10721090

10731091
The 3+ observation fit can also be interpreted through one explicitly supplied
10741092
RTD model without changing the resistance-domain fit. The result converts the
@@ -1081,8 +1099,9 @@ self-heating coefficient or dissipation constant.
10811099

10821100
The retained intercept/slope covariance can be propagated through the same model
10831101
into the fitted zero-power temperature and fitted temperature rises. It may come
1084-
from residual-scatter ordinary least squares or from supplied absolute resistance
1085-
standard uncertainties in the weighted fit. At each
1102+
from residual-scatter ordinary least squares, supplied absolute resistance standard
1103+
uncertainties in the weighted fit, or the supplied two-coordinate uncertainty model
1104+
in the York errors-in-variables fit. At each
10861105
sampled ``x = I²``, the fitted resistance sensitivity to ``(R0, k)`` is ``(1, x)``.
10871106
The temperature sensitivity vector is therefore the local ``dT/dR`` multiplied by
10881107
``(1, x)``, while the temperature-rise vector subtracts the corresponding
@@ -1168,8 +1187,9 @@ future statistically justified API concern.
11681187

11691188
The self-heating layer still does not automatically alter an RTD model or a
11701189
general uncertainty budget. Remaining 0.8.0 regression work is limited to
1171-
errors-in-variables handling when measurement-current uncertainty is material and
1172-
correlated-observation treatment where a defensible covariance model exists.
1190+
cross-observation covariance treatment where a defensible covariance model exists,
1191+
plus any experiment-specific residual acceptance criteria that can be stated without
1192+
inventing universal thresholds.
11731193

11741194
#### Portable model-definition format decision
11751195

docs/REFERENCES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,18 @@ variance are available. `rtd-sensor` keeps this response-uncertainty case separa
303303
from measurement-current uncertainty in the independent coordinate, which requires
304304
an errors-in-variables treatment.
305305

306+
York, D., Evensen, N. M., López Martínez, M., & De Basabe Delgado, J.
307+
(2004). Unified equations for the slope, intercept, and standard errors of the
308+
best straight line. *American Journal of Physics, 72*(3), 367–375.
309+
https://doi.org/10.1119/1.1632486
310+
311+
**Project use:** Implementation basis for the 3+ observation self-heating
312+
errors-in-variables fit when measurement-current uncertainty is material. York's
313+
straight-line formulation supports observation-specific uncertainty in both
314+
coordinates and correlation between the coordinate errors of each observation.
315+
`rtd-sensor` applies it to `(I², R)` after first-order propagation
316+
`u(I²) = 2 I u(I)` and does not infer covariance between separate observations.
317+
306318
Bureau International des Poids et Mesures, Consultative Committee for
307319
Thermometry. (2021). *Guide to the realization of the ITS-90: Platinum
308320
resistance thermometry*.

docs/ROADMAP.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ Implemented in the current 0.8.0 development checkpoint:
153153
retained normalized weights, chi-square/reduced-chi-square diagnostics, and
154154
parameter covariance determined directly from those supplied uncertainties rather
155155
than rescaled by residual scatter;
156+
- York errors-in-variables regression for 3+ observation fits when every observation
157+
has both measurement-current and resistance standard uncertainty, including
158+
first-order propagation of current uncertainty into the `` coordinate, optional
159+
within-observation current/resistance error correlation, chi-square diagnostics,
160+
and parameter covariance from the supplied coordinate-uncertainty model without
161+
residual rescaling;
156162
- model-based interpretation of the 3+ observation fit into zero-power, observed,
157163
and fitted temperatures together with observed/fitted `I²R` powers; and
158164
- first-order propagation of the full fitted intercept/slope covariance into the
@@ -173,10 +179,9 @@ Implemented in the current 0.8.0 development checkpoint:
173179

174180
Remaining 0.8.0 scope includes:
175181

176-
- errors-in-variables extensions to larger-observation fitting where measurement-
177-
current uncertainty is material, plus any defensible correlated-observation
178-
treatment and experiment-specific residual acceptance criteria that can be stated
179-
without inventing universal thresholds.
182+
- cross-observation covariance treatment where a defensible model exists, plus any
183+
experiment-specific residual acceptance criteria that can be stated without
184+
inventing universal thresholds.
180185

181186
The package will analyze supplied current/resistance observations. It will not
182187
control excitation current, ADCs, bridges, MAX31865 devices, or other acquisition

learn/api/self-heating.md

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ fit_zero_power_resistance(
7272
observations: Iterable[SelfHeatingObservation],
7373
*,
7474
resistance_standard_uncertainties_ohms: Iterable[float] | None = None,
75+
measurement_current_standard_uncertainties_a: Iterable[float] | None = None,
76+
current_resistance_error_correlations: Iterable[float] | None = None,
7577
context: SelfHeatingExperimentContext | None = None,
7678
) -> ZeroPowerResistanceFitResult
7779
```
@@ -91,9 +93,17 @@ The default multi-observation path uses **unweighted ordinary least squares** in
9193
resistance. If every observation has an absolute resistance standard uncertainty,
9294
pass those values with `resistance_standard_uncertainties_ohms`; the same function
9395
then uses inverse-variance weighted least squares with weights proportional to
94-
`1/u²`. The `` coordinate remains fixed/exact in both cases, so this is not an
95-
errors-in-variables treatment for uncertain measurement current. Optional
96-
``context`` is retained as non-behavioral provenance and does not alter the fit.
96+
`1/u²`. The `` coordinate remains fixed/exact in those two modes.
97+
98+
If every observation also has a measurement-current standard uncertainty, pass it
99+
with `measurement_current_standard_uncertainties_a`. The fit then uses York
100+
errors-in-variables regression in `(I², R)` coordinates. Current uncertainty is
101+
propagated to the squared-current coordinate with the first-order relation
102+
`u(I²) = 2 I u(I)`. Optional `current_resistance_error_correlations` supply one
103+
within-observation correlation coefficient per current/resistance pair; omitted
104+
coefficients are recorded as zero. The York path does not infer covariance between
105+
separate observations. Optional ``context`` remains non-behavioral provenance and
106+
does not alter any fit.
97107

98108
```python
99109
weighted_fit = self_heating.fit_zero_power_resistance(
@@ -106,10 +116,25 @@ print(weighted_fit.evidence.chi_squared)
106116
print(weighted_fit.evidence.reduced_chi_squared)
107117
```
108118

109-
The uncertainties must be finite, positive, and match the observation count. They
110-
are treated as absolute independent resistance-domain standard uncertainties and
111-
are never inferred from replicate scatter. `rtd-sensor` does not define a universal
112-
acceptable reduced-chi-square threshold.
119+
The uncertainty sequences must be finite, positive, and match the observation
120+
count. Errors-in-variables fitting requires both current and resistance standard
121+
uncertainties. Correlation coefficients must lie from `-1` through `1`. These values
122+
are supplied measurement evidence; `rtd-sensor` does not infer them from replicate
123+
scatter or shared instrumentation and does not define a universal acceptable
124+
reduced-chi-square threshold.
125+
126+
```python
127+
eiv_fit = self_heating.fit_zero_power_resistance(
128+
observations,
129+
resistance_standard_uncertainties_ohms=(0.002, 0.002, 0.005, 0.005),
130+
measurement_current_standard_uncertainties_a=(2e-7, 2e-7, 5e-7, 5e-7),
131+
current_resistance_error_correlations=(0.0, 0.0, 0.2, 0.2),
132+
)
133+
134+
print(eiv_fit.evidence.current_squared_standard_uncertainties_a2)
135+
print(eiv_fit.evidence.errors_in_variables_effective_weights)
136+
print(eiv_fit.evidence.chi_squared)
137+
```
113138

114139
## `assess_zero_power_extrapolation`
115140

@@ -230,13 +255,19 @@ residual_standard_deviation_ohms: float
230255
fitted_resistances_ohms: tuple[float, ...]
231256
context: SelfHeatingExperimentContext | None
232257
resistance_standard_uncertainties_ohms: tuple[float, ...] | None
258+
measurement_current_standard_uncertainties_a: tuple[float, ...] | None
259+
current_resistance_error_correlations: tuple[float, ...] | None
260+
current_squared_standard_uncertainties_a2: tuple[float, ...] | None
233261
effective_weights: tuple[float, ...] | None
262+
errors_in_variables_effective_weights: tuple[float, ...] | None
263+
errors_in_variables_iteration_count: int | None
234264
chi_squared: float | None
235265
reduced_chi_squared: float | None
236266
weighted_rms_residual_ohms: float | None
237267
method: (
238268
"ordinary_least_squares_resistance_vs_current_squared"
239269
| "inverse_variance_weighted_least_squares_resistance_vs_current_squared"
270+
| "york_errors_in_variables_resistance_vs_current_squared"
240271
)
241272
```
242273

@@ -262,13 +293,14 @@ Estimates fitted-parameter covariance using the statistical model retained by th
262293
fit. For an unweighted fit, the calculation uses residual variance
263294
`SSE / residual_degrees_of_freedom` and ordinary-least-squares covariance. For an
264295
inverse-variance weighted fit, covariance comes directly from the supplied absolute
265-
resistance standard uncertainties and is not rescaled by residual scatter or
266-
reduced chi-square. Measurement-current-squared coordinates remain fixed/exact in
267-
both cases.
296+
resistance standard uncertainties. For a York errors-in-variables fit, covariance
297+
comes from the York adjusted coordinates and the supplied current/resistance
298+
coordinate uncertainty model. Neither absolute-uncertainty path is rescaled by
299+
residual scatter or reduced chi-square.
268300

269-
Measurement-current uncertainty and correlated observation errors still require a
270-
different or larger statistical model. Fitted RTD-model covariance also remains
271-
separate.
301+
The York path can represent correlation between current and resistance errors
302+
within each observation. Correlation between separate observations still requires a
303+
larger covariance model. Fitted RTD-model covariance also remains separate.
272304

273305
## `ZeroPowerResistanceFitUncertaintyResult`
274306

@@ -355,19 +387,23 @@ propagate_zero_power_fit_temperature_uncertainty(
355387

356388
Propagates the full retained covariance of the fitted zero-power resistance and
357389
``dR/d(I²)`` slope through the supplied RTD model. The covariance may come from
358-
residual-scatter OLS or from supplied absolute resistance uncertainties in the
359-
weighted fit. The result reports fit-covariance uncertainty for the zero-power
360-
temperature, each fitted temperature, and each fitted temperature rise.
390+
residual-scatter OLS, supplied absolute resistance uncertainties in the weighted
391+
fit, or a York errors-in-variables coordinate-uncertainty model. The result reports
392+
fit-parameter-covariance uncertainty for the zero-power temperature, each fitted
393+
temperature, and each fitted temperature rise.
361394

362395
At sampled ``x = I²``, fitted resistance depends on the retained parameters as
363396
``R0 + k*x``. The fitted-temperature sensitivity vector is the local ``dT/dR``
364397
times ``(1, x)``. Temperature-rise sensitivities subtract the zero-power
365398
temperature sensitivity first, preserving the shared fitted intercept and the
366399
intercept/slope covariance.
367400

368-
This is first-order/local propagation. The RTD model is treated as fixed and no
369-
measurement-current uncertainty, additional resistance uncertainty, model-parameter
370-
covariance, or correlated experiment effects are inserted automatically.
401+
This is first-order/local propagation. For a York fit, measurement-current
402+
uncertainty has already influenced the fitted-parameter covariance, but no separate
403+
direct uncertainty term is added for the nominal sampled current coordinate used to
404+
report each fitted point. The RTD model is treated as fixed and no additional
405+
resistance uncertainty, model-parameter covariance, or cross-observation correlated
406+
experiment effects are inserted automatically.
371407

372408
## `ZeroPowerResistanceFitTemperatureUncertaintyResult`
373409

@@ -419,6 +455,14 @@ The two-current correction path is intentionally not accepted here. Its two poin
419455
exactly determine the resistance line, so the named context-bound characterization
420456
remains on the larger-observation path with residual diagnostics and fit covariance.
421457

458+
The current coefficient calculation also rejects York errors-in-variables fits.
459+
When measurement-current uncertainty is material, fitted ``I²R`` power depends
460+
directly on an uncertain current coordinate; propagating only the fitted intercept/
461+
slope covariance would omit that dependence. The EIV fit can still be used for the
462+
zero-power extrapolation and its temperature interpretation, but coefficient
463+
characterization remains on the fixed-current OLS/WLS paths until that downstream
464+
uncertainty model is defined.
465+
422466
## `SelfHeatingCoefficientResult`
423467

424468
**Introduced in:** rtd-sensor 0.8.0

0 commit comments

Comments
 (0)