[R] underdetermined system

Ravi Varadhan rvaradhan at jhmi.edu
Tue Oct 16 21:17:56 CEST 2007


Here is a solution using SVD:

w <- matrix(c(1, 5), ncol=2)
sw <- 2
w.svd <- svd(w)
sw %*% w.svd$u %*% diag(1/w.svd$d, length(w.svd$d)) %*% t(w.svd$v)


> sw %*% w.svd$u %*% diag(1/w.svd$d, length(w.svd$d)) %*% t(w.svd$v)
           [,1]      [,2]
[1,] 0.07692308 0.3846154
>

This, of course, has a smaller norm than (0, 0.4).

Ravi.

----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of yoooooo
Sent: Tuesday, October 16, 2007 3:02 PM
To: r-help at r-project.org
Subject: Re: [R] underdetermined system


Turns out someone asked this before ;)

http://tolstoy.newcastle.edu.au/R/e2/devel/07/04/2981.html


Ravi Varadhan wrote:
> 
> QR is good for overdetermined LS problems, and I don't think that it can
> be
> used for "minimum norm" solution of underdetrmined LS problems.  You need
> LAPACK's Fortran routine DGELS.  I am not sure if this currently available
> in R.
> 
> Ravi.
> 
>
----------------------------------------------------------------------------
> -------
> 
> Ravi Varadhan, Ph.D.
> 
> Assistant Professor, The Center on Aging and Health
> 
> Division of Geriatric Medicine and Gerontology 
> 
> Johns Hopkins University
> 
> Ph: (410) 502-2619
> 
> Fax: (410) 614-9625
> 
> Email: rvaradhan at jhmi.edu
> 
> Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
> 
>  
> 
>
----------------------------------------------------------------------------
> --------
> 
> 
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On
> Behalf Of yoooooo
> Sent: Tuesday, October 16, 2007 11:34 AM
> To: r-help at r-project.org
> Subject: [R] underdetermined system
> 
> 
> Hi, sorry, I'm an idiot.. and I know I'm missing something stupid.. 
> 
> I thought if we solve an underdetermine system with QR, my soln is:
> 
> min ||x|| (L2 sense)  such that Ax = b
> 
> then say i have:
> 
>> w <- matrix(c(1, 5), ncol=2)
>> sw = 2
>> qrW = qr(t(w) %*% w)
>> qr.coef(qrW, t(w) %*% sw)
>      [,1]
> [1,]    2
> [2,]   NA
> 
> but we also have soln (0, 2/5) which obviously has a smaller distance in
> L2
> than (2, 0). Am I missing something very obvious? Thanks a lot!!!!
> 
> - yoooooooooooooooooo
> 
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/underdetermined-system-tf4634837.html#a13235711
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context:
http://www.nabble.com/underdetermined-system-tf4634837.html#a13240230
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list