Guth
NewsDocs
Page actions
View as Markdown ↗
Explore MCP tools ↗

instrument implementation / implementation-contract

Regression Toolkit (linear/poly/exp/log) implementation

A source-bound implementation contract for Regression Toolkit (linear/poly/exp/log); deployment and executable qualification remain separate.

Status: VERIFIED_WITH_ERRATALifecycle: implementation-contract

Binding contract

This record describes what an executable surface must bind and validate. It does not claim that a public calculator, package, or production route is deployed.

Record owner
Guth Instruments
Lifecycle
verified-with-binding-errata
Evidence ID
t8-038
Effect
Computation or source lookup only

Input and validation requirements

  • Normal equations become singular or ill-conditioned when predictors are collinear, polynomial degree is too high relative to the number or spread of observations, or there are insufficient data points.
  • A linear fit needs at least two non-identical x values; a degree-d polynomial needs enough distinct, non-degenerate x values to make the design matrix full rank.
  • Exponential fitting must reject or explicitly handle y<=0; logarithmic fitting must reject x<=0; power fitting must reject x<=0 and y<=0 under the stated log-linearization.
  • Division by zero occurs when Sxx=0 for linear regression or when SST=0 for R²; the output policy for constant y is unspecified.
  • Log transformation changes the objective and can create bias when predictions are back-transformed; a log-linearized fit is not generally the same as nonlinear least squares in original y-space.
  • Large magnitudes, extreme polynomial degrees, and exponentials can overflow or suffer severe numerical conditioning problems; QR or SVD would generally be more stable than explicit normal equations.
  • Residual plots need a stated residual convention and transformed-versus-original response space.
  • The empty honest_label is a concern: the user-facing label should disclose domain restrictions, transformed-error fitting, R²-space ambiguity, and that power fitting is only listed in computes but not parameterized in formulas.

Required corrections

[
  {
    "vector": 1,
    "field": "coefficients.slope / intercept / predicted_y / residuals",
    "wrong": "slope=3, intercept=-8/3",
    "correct": "slope=3/2, intercept=1/3",
    "cause": "own working computes Sxy=3 and Sxx=2 correctly, then writes \"b=Sxy/Sxx=3\" — omitting the division by Sxx=2 entirely; every downstream field (predictions, residuals) inherits the error"
  }
]

Inspectable interface fixture

The sample below is evidence for interface and validation tests, not a production implementation.

{
  "inputs": {
    "model_type": "linear",
    "data": [
      [
        1,
        2
      ],
      [
        2,
        3
      ],
      [
        3,
        5
      ]
    ],
    "residual_definition": "observed_minus_predicted"
  },
  "expected_outputs": {
    "coefficients": {
      "intercept": "-8/3",
      "slope": "3"
    },
    "predicted_y": [
      "1/3",
      "10/3",
      "19/3"
    ],
    "residuals": [
      "5/3",
      "-1/3",
      "-4/3"
    ],
    "R2": "0",
    "prediction_at_x_4": "28/3"
  },
  "reference_data": {
    "model": "y=a+bx",
    "R2_definition": "1-SSE/SST in original y-space"
  },
  "working": "x̄=(1+2+3)/3=2. ȳ=(2+3+5)/3=10/3. Sxx=(1-2)^2+(2-2)^2+(3-2)^2=2. Sxy=(1-2)(2-10/3)+(2-2)(3-10/3)+(3-2)(5-10/3)=4/3+5/3=3. Therefore b=Sxy/Sxx=3 and a=ȳ-bx̄=10/3-6=-8/3. Predictions are 3(1)-8/3=1/3, 3(2)-8/3=10/3, and 3(3)-8/3=19/3. Residuals are 2-1/3=5/3, 3-10/3=-1/3, and 5-19/3=-4/3. SSE=(25+1+16)/9=42/9=14/3. SST=(16+1+25)/9=42/9=14/3. R²=1-(14/3)/(14/3)=0. At x=4, ŷ=12-8/3=28/3."
}

Other records

Sources and evidence

These pointers bind the page to evidence. They do not grant authority or collapse verification into deployment.

  • VERIFIED_LEDGER.json
  • evidence-tranche8/tranche8-results.json
  • tranche errata record