calibration_curve
Instrument calibration: unweighted or weighted least-squares straight line (or quadratic) of response against standard concentration, with residuals, R², standard errors, detection and quantitation limits (k s / slope), inverse prediction of an unknown with its confidence interval, and a lack-of-fit F test from replicate standards. Student's t and Fisher's F are computed from the incomplete beta function; no table is stored.
- Field
- Measurement and data
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 0.05 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001exact line y = 2x + 1 (closed form): slope 2, intercept 1, residuals 0, R2 1; inverse of y0 = 8 is x0 = 3.5 exactly (rounding tolerance only)passed
slope2 ± 2e-122lockedunder 0.01 % of the tolerance usedintercept1 ± 1e-121lockedunder 0.01 % of the tolerance usedmax_abs_residual0 ± 1e-120lockedunder 0.01 % of the tolerance usedresidual_sd0 ± 1e-120lockedunder 0.01 % of the tolerance usedr21 ± 1e-121lockedunder 0.01 % of the tolerance usedx_unknown3.5 ± 3.5e-123.5lockedunder 0.01 % of the tolerance usedlod0 ± 1e-120lockedunder 0.01 % of the tolerance usedr0002five-point set worked by hand with exact fractions (Sxx=10, Sxy=98/5): b=49/25, a=11/50, SSres=11/250, s=sqrt(11/750); LOD=3.3s/b, LOQ=10s/b; t(0.975,3) from the closed-form nu=3 t cdf; x0=(7-a)/b with the textbook s_x0 (rel 1e-9: exact arithmetic; t from a root solve, rel 1e-9)passed
slope1.96 ± 2e-091.96lockedunder 0.01 % of the tolerance usedintercept0.22 ± 2.2e-100.22lockedunder 0.01 % of the tolerance usedss_residual0.044 ± 4.4e-110.044lockedunder 0.01 % of the tolerance usedresidual_sd0.121106 ± 1.2e-100.121106lockedunder 0.01 % of the tolerance usedse_slope0.0382971 ± 3.8e-110.0382971lockedunder 0.01 % of the tolerance usedse_intercept0.127017 ± 1.3e-100.127017lockedunder 0.01 % of the tolerance usedr20.998856 ± 1e-090.998856lockedunder 0.01 % of the tolerance usedlod0.203903 ± 2e-100.203903lockedunder 0.01 % of the tolerance usedloq0.617888 ± 6.2e-100.617888lockedunder 0.01 % of the tolerance usedt_critical3.18245 ± 3.2e-093.18245lockedunder 0.01 % of the tolerance usedx_unknown3.45918 ± 3.5e-093.45918lockedunder 0.01 % of the tolerance useds_x_unknown0.0682783 ± 6.8e-110.0682783lockedunder 0.01 % of the tolerance usedx_unknown_ci_half_width0.217292 ± 2.2e-100.217292lockedunder 0.01 % of the tolerance usedr0003four standards, dof 2, unknown read twice (m=2): b=24/25, a=3/50, SSres=4/125; t(0.975,2)=0.95/sqrt(2*0.975*0.025) in closed form; x0=2.125 and s_x0 with 1/m (rel 1e-9)passed
slope0.96 ± 9.6e-100.96lockedunder 0.01 % of the tolerance usedintercept0.06 ± 6e-110.06lockedunder 0.01 % of the tolerance usedresidual_sd0.126491 ± 1.3e-100.126491lockedunder 0.01 % of the tolerance usedt_critical4.30265 ± 4.3e-094.30265lockedunder 0.01 % of the tolerance usedx_unknown2.125 ± 2.1e-092.125lockedunder 0.01 % of the tolerance useds_x_unknown0.119905 ± 1.2e-100.119905lockedunder 0.01 % of the tolerance usedx_unknown_ci_low1.60909 ± 1.6e-091.60909lockedunder 0.01 % of the tolerance usedx_unknown_ci_high2.64091 ± 2.6e-092.64091lockedunder 0.01 % of the tolerance usedr0004weighted line, weights 4:3:2:1 rescaled to sum n (exact fractions): xbar_w=2, b=47/50, a=1/5, SSres_w=9/125, s_b=s/2, s_a=s sqrt(1/4+1); unknown y0=3 with weight 3 -> x0=(3-a)/b and weighted s_x0 (rel 1e-9)passed
slope0.94 ± 9.4e-100.94lockedunder 0.01 % of the tolerance usedintercept0.2 ± 2e-100.2lockedunder 0.01 % of the tolerance usedresidual_sd0.189737 ± 1.9e-100.189737lockedunder 0.01 % of the tolerance usedse_slope0.0948683 ± 9.5e-110.0948683lockedunder 0.01 % of the tolerance usedse_intercept0.212132 ± 2.1e-100.212132lockedunder 0.01 % of the tolerance usedx_unknown2.97872 ± 3e-092.97872lockedunder 0.01 % of the tolerance useds_x_unknown0.232152 ± 2.3e-100.232152lockedunder 0.01 % of the tolerance usedr0005lack of fit, duplicates at 3 levels: SSpe=6/100, SSlof=1/3, F(1,3)=50/3; p from F(1,3)=t(3)^2 and the closed-form nu=3 t cdf (rel 1e-9)passed
slope1 ± 1e-091lockedunder 0.01 % of the tolerance usedintercept0.166667 ± 1.7e-100.166667lockedunder 0.01 % of the tolerance usedss_pure_error0.06 ± 6e-110.06lockedunder 0.01 % of the tolerance usedss_lack_of_fit0.333333 ± 3.3e-100.333333lockedunder 0.01 % of the tolerance usedlack_of_fit_f16.6667 ± 1.7e-0816.6667lockedunder 0.01 % of the tolerance usedlack_of_fit_p0.0265479 ± 2.7e-100.0265479lockedunder 0.01 % of the tolerance usedlack_of_fit_significant= truetruelockedexact matchr0006exact quadratic y = 1 + 2x + 0.5x^2 (closed form): coefficients recovered, y0 = 11.5 inverts to the root x0 = 3; t(0.975, nu=1) = tan(0.475 pi) = 12.7062... (Cauchy, closed form)passed
intercept1 ± 1e-101lockedunder 0.01 % of the tolerance usedslope2 ± 2e-102lockedunder 0.01 % of the tolerance usedquadratic0.5 ± 5e-110.5lockedunder 0.01 % of the tolerance usedx_unknown3 ± 3e-103lockedunder 0.01 % of the tolerance usedt_critical12.7062 ± 1.3e-0812.7062lockedunder 0.01 % of the tolerance usedr0007blank-based limits on the five-point set: LOD = 3.3 x 0.05 / 1.96, LOQ = 10 x 0.05 / 1.96 (closed form, rel 1e-9)passed
lod0.0841837 ± 8.4e-110.0841837lockedunder 0.01 % of the tolerance usedloq0.255102 ± 2.6e-100.255102lockedunder 0.01 % of the tolerance used
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
x | Concentrations of the standards, one per reading; replicate readings repeat the concentration. | ||
y | Instrument response of each standard, paired with x. | ||
x_unit | 1 | Unit of concentration (e.g. "mg/L"); the concentration readings carry it. "1" for arbitrary units. | |
y_unit | 1 | Unit of the response; the response readings carry it. "1" for arbitrary units (absorbance, counts, peak area). | |
model | linear | y = a + b x, or y = a + b x + c x^2. | |
weighting | none | Weights of the standards; they are rescaled so they sum to n (textbook convention). | |
weights | 1 | With weighting="custom": one weight per reading, e.g. 1/s_i^2. | |
weight_unknown | 1 | With weighting="custom": the weight of one reading of the unknown, on the scale of weights. Default: the mean weight. | |
y_unknown | Replicate responses of the unknown sample (m of them); its concentration is read from the curve. | ||
confidence | 1 | 0.95 | Two-sided confidence level for t intervals and the lack-of-fit test (alpha = 1 - confidence). |
lod_basis | residual | Sigma in LOD = k_lod sigma / b: the residual standard deviation s_y/x, the standard error of the intercept, or blank_sd. | |
blank_sd | Standard deviation of replicate blank readings, with lod_basis="blank". | ||
k_lod | 1 | 3.3 | Detection-limit factor (ICH Q2: 3.3). |
k_loq | 1 | 10 | Quantitation-limit factor (ICH Q2: 10). |
Readings
| Name | Unit | Meaning |
|---|---|---|
model | linear or quadratic | |
equation | the fitted curve as text | |
intercept | a | |
slope | b, in the unit of y per unit of x (sensitivity) | |
quadratic | c, in the unit of y per unit of x squared; null for a line | |
se_intercept | ||
se_slope | in the unit of y per unit of x | |
se_quadratic | in the unit of y per unit of x squared | |
slope_ci_low | in the unit of y per unit of x | |
slope_ci_high | in the unit of y per unit of x | |
intercept_ci_low | ||
intercept_ci_high | ||
x_min | ||
x_max | ||
x_mean | weighted mean concentration | |
y_mean | weighted mean response | |
sxx | weighted sum of squared deviations of x, unit of x squared | |
ss_residual | weighted residual sum of squares, unit of y squared | |
residual_sd | s_y/x = sqrt(SS_res / (n - p)) | |
max_abs_residual | ||
residuals | ||
r2 | 1 | |
adjusted_r2 | 1 | |
t_critical | 1 | two-sided Student t at the confidence level, n - p degrees of freedom |
lod_sigma | ||
lod | detection limit k_lod sigma / |b| | |
loq | quantitation limit k_loq sigma / |b| | |
y_unknown_mean | ||
x_unknown | x0 = (y0 - a) / b | |
s_x_unknown | (s/b) sqrt(1/(m w0) + 1/n + (y0 - ybar)^2 / (b^2 Sxx)) | |
x_unknown_ci_low | ||
x_unknown_ci_high | ||
x_unknown_ci_half_width | ||
x_unknown_rel_sd_pct | % | |
weight_unknown_scaled | 1 | |
g_factor | 1 | (t s_b / b)^2; above 0.05 the symmetric interval is approximate |
ss_pure_error | unit of y squared | |
ss_lack_of_fit | unit of y squared | |
lack_of_fit_f | 1 | |
lack_of_fit_p | 1 | |
lack_of_fit_significant | true when p < 1 - confidence; null when it cannot be tested | |
point_count | 1 | |
level_count | 1 | |
degrees_of_freedom | 1 | |
df_pure_error | 1 | |
df_lack_of_fit | 1 | |
unknown_replicates | 1 | |
points | ||
all_ok | no warnings | |
warnings | ||
notes | ||
files | out/points.csv (x, y, weight, fitted, residual, standardised residual) and out/curve.csv (fit with confidence band of the mean and prediction band of a single reading) |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.