Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #least_squares for least squares approximation #539

Merged
merged 2 commits into from
Oct 26, 2016

Conversation

gtamba
Copy link

@gtamba gtamba commented Aug 28, 2016

Fixes #513

Commits :-

  1. Slight modification of #unmqr and #ormqr to prevent one of the input multiplicands from being overwritten

  2. Adding of #least_squares

Usage :-

a = NMatrix.new([3,2], [2.0, 0, -1, 1, 0, 2]) 
b = NMatrix.new([3,1], [1.0, 0, -1])

a.least_squares(b)

=> 
[
  [0.33333333333333326]
  [-0.3333333333333334]
]

Currently only works for matrices that are not rank-deficient which can be tackled when QR factorization with column pivoting gets wrapped from Lapack. Would add a few more tests very soon.

@gtamba gtamba changed the title Add #least_squares for least squares approximationm [WIP] Add #least_squares for least squares approximation [WIP] Aug 28, 2016
@@ -533,6 +533,66 @@ def solve(b, opts = {})

#
# call-seq:
# least_squares -> NMatrix
#
# Provides the linear least squares approximation of an under-determined
Copy link
Author

Choose a reason for hiding this comment

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

missed the word "system" somehow.

@translunar translunar mentioned this pull request Oct 12, 2016
@translunar
Copy link
Member

@gau27 Can you please rebase against master? I think we've sorted out Travis-CI problems.

@gtamba gtamba force-pushed the master branch 2 times, most recently from 953257b to b81763b Compare October 25, 2016 06:55
@gtamba
Copy link
Author

gtamba commented Oct 25, 2016

The Travis build is failing because of a faulty spec I added this morning, I don't have Lapack available on my work laptop right now to check it out, will investigate when I reach home.

@gtamba gtamba changed the title Add #least_squares for least squares approximation [WIP] Add #least_squares for least squares approximation Oct 25, 2016
@translunar translunar merged commit 00b8699 into SciRuby:master Oct 26, 2016
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