{"id":"regression-residuals-check","version":"1.0.0","description":"Check claimed residuals and SSE for given regression coefficients and exact samples; reports the first wrong residual.","supported_operations":["verify regression residuals","check sum of squared errors of a fit","are these residuals correct for my model","validate sse of a linear regression exactly","check residual table of a fitted line","verify fitted minus observed values exactly","בדיקת שאריות של רגרסיה"],"unsupported_operations":["checking that the coefficients are optimal (use regression-normal-equations-check)","standardized or studentized residuals","R squared or residual standard error","approximate or tolerance-based comparison"],"semantics":["Reference: NIST/SEMATECH e-Handbook of Statistical Methods sec. 4.1.4.1 and 4.4.3.1 (ordinary least squares, normal equations); exact rational arithmetic.","Model (NIST e-Handbook 4.1.4.1): y_i = sum_j beta_j X_ij + e_i; X has a leading column of ones when intercept is true (required, no default), then the x features in order; coefficient 0 is the intercept when present.","Values are exact strings: integer, decimal (\"3.5\") or fraction (\"7/2\"), never JSON numbers or exponents; comparisons are exact and outputs canonical reduced fractions. difference = claimed - actual.","Ragged rows, len(y) != rows or empty x are invalid_input; a claimed vector of the wrong length is valid:false dimension_mismatch, checked first.","Residuals are observed minus fitted, e_i = y_i - sum_j beta_j X_ij, and SSE = sum e_i^2 (NIST e-Handbook 4.4.3.1). The claimed coefficients are taken as given; rank is not checked.","Check order: coefficient count, residual count, residuals in sample order (residual_mismatch), then SSE (sse_mismatch). sse is the exact SSE of the claimed coefficients, or null when the coefficient count is wrong.","Limits: 256 samples, 8 features, 30 digits per sample value, 1000 digits per claimed value, 9 claimed coefficients, 256 claimed residuals, and common denominators of at most 100 digits for the x values and for the y values and 1000 digits for the claimed coefficients; over a limit is limit_exceeded."],"limits":{"max_samples":256,"max_features":8,"max_sample_digits":30,"max_claim_digits":1000,"max_data_denominator_digits":100,"max_claim_denominator_digits":1000},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["x","y","intercept","coefficients","residuals","sse"],"properties":{"x":{"type":"array","minItems":1,"maxItems":256,"items":{"type":"array","minItems":1,"maxItems":8,"items":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}}},"y":{"type":"array","minItems":1,"maxItems":256,"items":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}},"intercept":{"type":"boolean"},"coefficients":{"type":"array","maxItems":9,"items":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}},"residuals":{"type":"array","maxItems":256,"items":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}},"sse":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}}},"output_schema":{"type":"object","additionalProperties":false,"required":["valid","reason","sse","first_discrepancy","reference_version"],"properties":{"valid":{"type":"boolean"},"reason":{"type":["string","null"],"enum":[null,"dimension_mismatch","residual_mismatch","sse_mismatch"]},"sse":{"type":["string","null"],"pattern":"^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$"},"first_discrepancy":{"type":["object","null"],"additionalProperties":false,"required":["check","index","claimed","actual","difference","expected_length","claimed_length","rank","dependent_column"],"properties":{"check":{"type":"string","enum":["dimensions","residuals","sse"]},"index":{"type":["integer","null"],"minimum":0},"claimed":{"type":["string","null"]},"actual":{"type":["string","null"]},"difference":{"type":["string","null"]},"expected_length":{"type":["integer","null"],"minimum":0},"claimed_length":{"type":["integer","null"],"minimum":0},"rank":{"type":["integer","null"],"minimum":0},"dependent_column":{"type":["integer","null"],"minimum":0}}},"reference_version":{"type":"string","const":"NIST/SEMATECH e-Handbook of Statistical Methods sec. 4.1.4.1 and 4.4.3.1 (ordinary least squares, normal equations); exact rational arithmetic"}}},"examples":[{"input":{"x":[["1"],["2"],["3"],["4"]],"y":["6","5","7","10"],"intercept":true,"coefficients":["3.5","1.4"],"residuals":["1.1","-1.3","-0.7","0.9"],"sse":"4.2"},"output":{"valid":true,"reason":null,"sse":"21/5","first_discrepancy":null,"reference_version":"NIST/SEMATECH e-Handbook of Statistical Methods sec. 4.1.4.1 and 4.4.3.1 (ordinary least squares, normal equations); exact rational arithmetic"}},{"input":{"x":[["1"],["2"],["3"],["4"]],"y":["6","5","7","10"],"intercept":true,"coefficients":["3.5","1.4"],"residuals":["-1.1","1.3","0.7","-0.9"],"sse":"4.2"},"output":{"valid":false,"reason":"residual_mismatch","sse":"21/5","first_discrepancy":{"check":"residuals","index":0,"claimed":"-1.1","actual":"11/10","difference":"-11/5","expected_length":null,"claimed_length":null,"rank":null,"dependent_column":null},"reference_version":"NIST/SEMATECH e-Handbook of Statistical Methods sec. 4.1.4.1 and 4.4.3.1 (ordinary least squares, normal equations); exact rational arithmetic"}}],"execute_url":"/v1/tools/regression-residuals-check/versions/1.0.0/execute"}