friendly / matlib

Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics
http://friendly.github.io/matlib/
65 stars 16 forks source link

problem in ?GramSchmidt #27

Closed john-d-fox closed 4 years ago

john-d-fox commented 4 years ago

Hi,

I noticed that ?GramSchmidt has this example:

# non-invertible matrix; hence, its basis is not orthonormal
(xx <- matrix(c( 1:3, 3:1, 1, 0, -1), 3, 3))
crossprod(xx)
(zz <- GramSchmidt(xx))
zapsmall(crossprod(zz))

The statement that the basis isn't orthonormal is wrong and contradicted by the last line of the example. Maybe what was meant is that its dimension is less than the number of columns in xx?

John

friendly commented 4 years ago

You are right -- good catch, and thx for filing this as an issue.

I don't recall who or why this example was included. Here is replacement text for this example. Does this satisfy? If so, I'll commit this replacement.

# non-invertible matrix; hence, it is of deficinent rank
(xx <- matrix(c( 1:3, 3:1, 1, 0, -1), 3, 3))
R(xx)
crossprod(xx)
# GramSchmidt finds an orthonormal basis
(zz <- GramSchmidt(xx))
zapsmall(crossprod(zz))
philchalmers commented 4 years ago

Looks like it was me: https://github.com/friendly/matlib/blame/f2f11592b424252497584ca345a7c7cd04a9e853/R/GramSchmidt.R#L29

Not sure why I wrote that. I agree, deficient rank is a better description.

john-d-fox commented 4 years ago

Hi Michael,

Sure, that's fine, though "deficinent" is misspelled.

Best, John

On Feb 15, 2020, at 1:45 PM, Michael Friendly notifications@github.com wrote:

You are right -- good catch, and thx for filing this as an issue.

I don't recall who or why this example was included. Here is replacement text for this example. Does this satisfy? If so, I'll commit this replacement.

non-invertible matrix; hence, it is of deficinent rank

(xx <- matrix(c( 1:3, 3:1, 1, 0, -1), 3, 3)) R(xx) crossprod(xx)

GramSchmidt finds an orthonormal basis

(zz <- GramSchmidt(xx)) zapsmall(crossprod(zz))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.