Skip to content

Fix underdetermined regularized least squares#45

Open
RobbieRao wants to merge 1 commit into
google:mainfrom
RobbieRao:agent/fix-underdetermined-ridge
Open

Fix underdetermined regularized least squares#45
RobbieRao wants to merge 1 commit into
google:mainfrom
RobbieRao:agent/fix-underdetermined-ridge

Conversation

@RobbieRao

Copy link
Copy Markdown

Summary

  • build the Tikhonov regularization block from the number of coefficients
  • append the matching number of zero rows to vector and matrix right-hand sides
  • cover underdetermined systems in both solver implementations

Root cause

The augmented least-squares system used an N x M identity matrix and padded
the right-hand side with N rows, where N is the number of equations and M
is the number of coefficients. For underdetermined systems (N < M), this left
some coefficients unregularized and produced a solution that did not minimize
the documented ridge objective.

For example, with A = [[1, 1]], b = [1], and regularization weight 1, the
expected ridge solution is [1/3, 1/3]; the previous implementation returned
approximately [0, 1].

Impact

Underdetermined systems now solve the documented regularized least-squares
objective. Square and overdetermined systems retain the same mathematical
result.

Testing

  • python gnm/shape/run_all_tests.py — 278 passed, 2 skipped
  • pylint gnm/shape/fitting_utils/regularized_least_squares.py gnm/shape/fitting_utils/regularized_least_squares_test.py

@google-cla

google-cla Bot commented Jul 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@RobbieRao

Copy link
Copy Markdown
Author

@googlebot rescan

@RobbieRao
RobbieRao force-pushed the agent/fix-underdetermined-ridge branch from e7d12af to bf15c45 Compare July 23, 2026 17:18
@RobbieRao
RobbieRao marked this pull request as ready for review July 23, 2026 17:29
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.

1 participant