Skip to content

feat(HF-221): add LINEST regression function - #1769

Draft
Tobiadefami wants to merge 5 commits into
developfrom
feature/hf-221-linest
Draft

Tobiadefami wants to merge 5 commits into
developfrom
feature/hf-221-linest

Conversation

@Tobiadefami

@Tobiadefami Tobiadefami commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Context

Adds LINEST(known_y, [known_x], [const], [stats]) for simple and multiple linear regression, including an optional intercept and the complete five-row statistics result. Supports row and column layouts, omitted predictors, redundant predictors, and array expressions.

Uses pivoted Householder QR and triangular solves for coefficient uncertainties. Standard errors accumulate scaled magnitudes with Math.hypot, avoiding overflow or underflow from intermediate squares when the final uncertainty is representable. Includes localized function names, catalogue metadata, JSDoc, documentation, and a changelog entry.

Compatibility limits

  • Output dimensions are fixed before evaluation. stats must be constant; references or calculated expressions return #VALUE!. Input expressions that change the predicted predictor count also return #VALUE!. Referenced const values can recalculate normally.
  • Numerical differences remain for nearly dependent predictors, effectively perfect fits, and extreme input scales. The implementation does not emulate observed Excel failures at extreme scales. Other intermediate calculations can still overflow or underflow; these limits are documented.

How did you test your changes?

Compared complete result matrices and error types against Excel Online observations. Added regression coverage for finite coefficient/intercept uncertainties at extreme scales and comparisons that cannot accept zero for tiny nonzero results.

Validation: 124 focused LINEST tests passed; the full Jest suite passed (503 suites, 6,357 tests); Chrome 153 and Firefox 155 each passed 6,357 tests. Three existing tests are skipped in each full suite. Compile, function documentation generation, full lint (zero errors), and the LINEST benchmark passed. The repository-wide performance checks also passed.

Related task: HF-221.

@cla-external-contractor-signup

Copy link
Copy Markdown

@Tobiadefami thanks for the pull request. No CLA step needed here — our records show you signed the Contributor License Agreement on 2026-07-31. That signature came from our previous signing form and has been carried over, so there is nothing for you to re-sign.

@qunabu

qunabu commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Task linked: HF-221 Function LINEST

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 64b6393. Configure here.

const interceptError = fitIntercept ? finiteValue(fit.interceptError) : new CellError(ErrorType.NA)
result.push([...fit.standardErrors].reverse().map(finiteValue).concat(interceptError))
result.push([finiteValue(rSquared), finiteValue(Math.sqrt(variance))])
result.push([f, fit.degreesOfFreedom])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Degenerate LINEST stats emit zeros

Medium Severity

When residual degrees of freedom is 0 (exact interpolation, including the common two-point LINEST with stats enabled), uncomputable uncertainties are emitted as 0 and F becomes #NUM!. Excel and Sheets return #N/A for the coefficient standard errors, residual standard error, and F in that case, so a zero standard error can look like a precise fit instead of an undefined statistic.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 64b6393. Configure here.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Performance comparison of head (b8a20aa) vs base (c920375)

                                     testName |   base |   head | change
------------------------------------------------------------------------
                                      Sheet A | 514.72 | 492.23 | -4.37%
                                      Sheet B | 169.14 | 157.19 | -7.07%
                                      Sheet T | 147.79 | 139.03 | -5.93%
                                Column ranges | 479.95 | 470.71 | -1.93%
                                Sorted lookup |  14096 |  14024 | -0.51%
Sheet A:  change value, add/remove row/column |   17.3 |  15.62 | -9.71%
 Sheet B: change value, add/remove row/column | 139.69 | 133.06 | -4.75%
                   Column ranges - add column | 151.76 | 150.11 | -1.09%
                Column ranges - without batch | 457.69 | 461.77 | +0.89%
                        Column ranges - batch |    112 | 114.39 | +2.13%

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 10, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
hyperformula-docs b8a20aa Commit Preview URL

Branch Preview URL
Sep 14 2026, 07:01 PM

@Tobiadefami
Tobiadefami marked this pull request as draft September 14, 2026 18:52
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.38%. Comparing base (c920375) to head (b8a20aa).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1769      +/-   ##
===========================================
+ Coverage    97.32%   97.38%   +0.05%     
===========================================
  Files          195      197       +2     
  Lines        15739    15982     +243     
  Branches      3390     3525     +135     
===========================================
+ Hits         15318    15564     +246     
+ Misses         421      410      -11     
- Partials         0        8       +8     
Files with missing lines Coverage Δ
src/error-message.ts 100.00% <100.00%> (ø)
src/i18n/languages/csCZ.ts 100.00% <ø> (ø)
src/i18n/languages/daDK.ts 100.00% <ø> (ø)
src/i18n/languages/deDE.ts 100.00% <ø> (ø)
src/i18n/languages/enGB.ts 100.00% <ø> (ø)
src/i18n/languages/esES.ts 100.00% <ø> (ø)
src/i18n/languages/fiFI.ts 100.00% <ø> (ø)
src/i18n/languages/frFR.ts 100.00% <ø> (ø)
src/i18n/languages/huHU.ts 100.00% <ø> (ø)
src/i18n/languages/idID.ts 100.00% <ø> (ø)
... and 12 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants