[SciPy-User] qr decompostion gives negative q, r ?

Virgil Stokes vs@it.uu...
Tue Nov 20 18:49:44 CST 2012


On 2012-11-21 00:55, Charles R Harris wrote:
>
>
> On Tue, Nov 20, 2012 at 4:26 PM, Virgil Stokes <vs@it.uu.se 
> <mailto:vs@it.uu.se>> wrote:
>
>     On 2012-11-21 00:11, Charles R Harris wrote:
>>
>>
>>     On Tue, Nov 20, 2012 at 3:59 PM, Virgil Stokes <vs@it.uu.se
>>     <mailto:vs@it.uu.se>> wrote:
>>
>>         On 2012-11-20 23:43, Charles R Harris wrote:
>>>
>>>
>>>         On Tue, Nov 20, 2012 at 3:03 PM, Virgil Stokes <vs@it.uu.se
>>>         <mailto:vs@it.uu.se>> wrote:
>>>
>>>             On 2012-11-20 22:33, Da?id wrote:
>>>             > The QR descomposition is finding two matrices with
>>>             certain properties such that:
>>>             >
>>>             > A = Q·R
>>>             >
>>>             > But, if both Q and R are multiplied by -1, (-Q)·(-R) =
>>>             Q·R = A, still
>>>             > the same matrix. If Q is orthogonal, -Q is also. The
>>>             sign is,
>>>             > therefore, arbitrary.
>>>             >
>>>             > On Tue, Nov 20, 2012 at 12:01 AM, Virgil Stokes
>>>             <vs@it.uu.se <mailto:vs@it.uu.se>> wrote:
>>>             >> I am using the latest versions of numpy (from
>>>             >> numpy-1.7.0b2-win32-superpack-python2.7.exe) and
>>>             scipy (from
>>>             >> scipy-0.11.0-win32-superpack-python2.7.exe ) on a
>>>             windows 7 (32-bit)
>>>             >> platform.
>>>             >>
>>>             >> I have used
>>>             >>
>>>             >> import numpy as np
>>>             >> q,r = np.linalg.qr(A)
>>>             >>
>>>             >> and compared the results to what I get from MATLAB
>>>             (R2010B)
>>>             >>
>>>             >> [q,r] = qr(A)
>>>             >>
>>>             >> The q,r returned from numpy are both the negative of
>>>             the q,r returned
>>>             >> from MATLAB for the same matrix A. I believe that
>>>             theq,r returned from
>>>             >> MATLAB are correct. Why am I getting their negative
>>>             from numpy?
>>>             >>
>>>             >> Note, I have tried this on several different matrices
>>>             ---  numpy always
>>>             >> gives the negative of MATLAB's.
>>>             >>
>>>             >> _______________________________________________
>>>             >> SciPy-User mailing list
>>>             >> SciPy-User@scipy.org <mailto:SciPy-User@scipy.org>
>>>             >> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>             > _______________________________________________
>>>             > SciPy-User mailing list
>>>             > SciPy-User@scipy.org <mailto:SciPy-User@scipy.org>
>>>             > http://mail.scipy.org/mailman/listinfo/scipy-user
>>>             Thanks David,
>>>             I am well aware of this; but, I am using the QR
>>>             decomposition for a
>>>             convariance (PD matrix) and the negative R is not very
>>>             useful in this
>>>             case and the numpy result, IMHO should not be the default.
>>>
>>>
>>>         What is your application?
>>         My application is the propagation of the factorized R matrix
>>         in the Kalman filter, where the QR factorization is for the
>>         covariance matrix in the KF recursions.
>>
>>
>>     That is what I suspected. However, the factorized matrices are
>>     usually U^t*D*U or U^t * U, so I think you are doing something wrong.
>     No Chuck,
>     You are referring to Bierman's factorization which is just one of
>     the factorizations possible. I am using a standard and
>     well-documented form of the so-called "square-root" Kalman filters
>     (just Google on this and be enlightened). Again, there many
>     papers/books that discuss the QR factorization implementation for
>     both the Kalman filter and Kalman smoother.
>
>
> Yes I am familiar with square root Kalman filters, I've even written a 
> few.
>
> Chuck
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
Sorry,
It is now 01:49 in Stockholm and I need to get a few hours of sleep. I 
will try to respond to further comments/questions on this topic tomorrow 
morning.

Thanks for looking at this problem. I believe that this is a serious 
issue that does deserve some attention.

Best, V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20121121/a5ca4047/attachment.html 


More information about the SciPy-User mailing list