Calculation contract
slope = sample_cov(x,y)/sample_var(x); intercept = mean(y) - slope*mean(x)| Input | Allowed values | Meaning |
|---|---|---|
| x | 3-250 finite numbers; each -1000000 to 1000000 | Explanatory values, nonconstant |
| y | Same length as x; each -1000000 to 1000000 | Aligned response values |
Method and interpretation
The fixture pairs 1,2,3,4 with 2,4,5,7. The fitted slope is 1.6 and the intercept is 0.5, with residual sum of squares 0.2. These numbers describe the supplied pairs; they do not identify a causal mechanism or establish a forecasting relationship.
The implementation uses the pinned Simple Statistics least-squares function and separately calculates residual fit. Independent Python checks use centered sums, providing a second arithmetic path. Constant x is rejected because no slope is identified; constant y retains a valid fit but withholds R-squared.
Where the reference stops
No p-values, robust standard errors, confidence intervals, multiple regressors or out-of-sample predictions are implied. Large offsets with very small variation can be numerically ill-conditioned; rescale before interpreting. This bounded teaching implementation is not a statistical certification.
Published synthetic inputs
{
"x": [
1,
2,
3,
4
],
"y": [
2,
4,
5,
7
]
}Frozen calculation output
{
"slope": 1.6,
"intercept": 0.5,
"r_squared": 0.9846153846153847,
"residual_sum_squares": 0.1999999999999999,
"observations": 4
}Univariate in-sample least squares with an intercept. R-squared is withheld for constant response; no inference or out-of-sample accuracy is supplied.
Verification coverage
- Known line, residual sums, constant-response and constant-explanatory cases.
- Input alignment and missing-value rejection tested.
Unit and independent-reference checks test arithmetic and rejection rules, not future investment performance.
Method references
Read the assumptions in context
Statistical estimationRegression fit is not forecast evidence
Separate least-squares estimation, conditional predictions and genuinely unseen forecast evaluation, including what a high fitted R-squared cannot establish.
Validation examplesArithmetic tests are not empirical validation
Identify what deterministic fixtures can verify, what they leave untested and why correctly implemented statistics do not establish investment usefulness.