fuzzy test for row equivalency#1427
Open
Alex-Jordan wants to merge 1 commit into
Open
Conversation
427cbfc to
e9319c2
Compare
Contributor
Author
|
I updated the top comment here, partly to fix typos, but also to explain a little more about what the comparison actually does. In another thread, @somiaj and I were talking about actually implementing an RREF algorithm. We could do that too, I just couldn't think of a way to avoid extraneous pivot positions popping up from machine rounding. That situation would create "false negatives" where two matrices that should be considered row equivalent would not be. But here, the algorithm goes the other way. It may create "false positives" because of the fuzzy tolerances. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an
isREQmethod for Matrix objects. Used like$A->isREQ($B).This is a "fuzzy " check that avoids both machine rounding issues and student rounding issues (for example if they enter something like 0.3333 instead of 1/3). Instead of reducing each matrix to RREF (which could introduce extraneous pivot positions from machine rounding), this approach compares the two row spaces. If each row from one matrix is "close enough" to the other matrix's row space, then the algorithm effectively declares that row to be in the other matrix's row space. "Close enough" is based on normalizing nonzero rows to length 1, and then the usual fuzzy tolerances for comparing that normalized row and its projection onto the other matrix's row space.
For example,
Matrix([ 3, 1 ], [ 1, 1 / 3 ])andMatrix([ 1, 0.3333 ], [ 0, 0 ])will be considered row equivalent.But
Matrix([ 3, 1 ], [ 1, 1 / 3 ])andMatrix([ 1, 0.33 ], [ 0, 0 ])will not be.And of course
Matrix([ 3, 1 ], [ 1, 1 / 3 ])andMatrix([ 1, 0], [ 0, 1 ])will not be.For questions that ask a student to completely reduce
$A, a checker could check$student->isRREF() && $student->isREQ($A).