Serving the Quantitative Finance Community

 
User avatar
terrorbyte
Topic Author
Posts: 3
Joined: July 14th, 2002, 3:00 am

** Spectral Decomposition **

May 21st, 2004, 4:36 pm

I am building Monte Carlo VaR and have a dreaded Correlation Matrix that is not positive semi-definite. Cholesky is dying on me. So, I want to do a spectral decomposition on the matrix to "cleanse" it ;-)Does anyone have psuedo-code/ procedure explaining how to do this?It seems extremely easy (calcing eigenvalues and vectors etc) but, being an IT person, I am struggling with Jackels book as the Greek lettters seem all Greek to me ;-)
 
User avatar
ametrano
Posts: 1
Joined: July 14th, 2002, 3:00 am

** Spectral Decomposition **

May 22nd, 2004, 4:37 pm

You will find C++ code for Jackel algorythm using spectral decomposition in QuantLib.Start from ql/Math/pseudosqrt.cpp.hope it helpsciao -- Nando
 
User avatar
terrorbyte
Topic Author
Posts: 3
Joined: July 14th, 2002, 3:00 am

** Spectral Decomposition **

May 22nd, 2004, 7:02 pm

Nando,Great job and thanks for your help! That is far more than I had hoped for ;-)Do you have an idea for when you intend to implement the Hypersphere Decomposition? I noted in Jackal's book that the Spectral Decomp was a good starting point before undertaking the Hypersphere Decomp.RegardsTerror
 
User avatar
Nonius
Posts: 0
Joined: January 22nd, 2003, 6:48 am

** Spectral Decomposition **

May 24th, 2004, 6:09 am

QuoteOriginally posted by: ametranoYou will find C++ code for Jackel algorythm using spectral decomposition in QuantLib.Start from ql/Math/pseudosqrt.cpp.hope it helpsciao -- Nandoon a related topic, Nando, it would be cool if the eigens were ordered in your symmetric diagonalization routine.
 
User avatar
ametrano
Posts: 1
Joined: July 14th, 2002, 3:00 am

** Spectral Decomposition **

May 24th, 2004, 3:34 pm

> it would be cool if the eigens were ordered in your symmetric diagonalization routine.QuantLib is striving for coolness and they are indeed ordered... or at least they should be.Which version of QuantLib are you using? You might have an old one. If you have a matrix for which QuantLib doesn't order the eigenvalues, please post it here and I'll give a look at it.ciao -- Nando
 
User avatar
Nonius
Posts: 0
Joined: January 22nd, 2003, 6:48 am

** Spectral Decomposition **

May 25th, 2004, 11:56 am

QuoteOriginally posted by: ametrano> it would be cool if the eigens were ordered in your symmetric diagonalization routine.QuantLib is striving for coolness and they are indeed ordered... or at least they should be.Which version of QuantLib are you using? You might have an old one. If you have a matrix for which QuantLib doesn't order the eigenvalues, please post it here and I'll give a look at it.ciao -- Nandoon my laptop running 2003-11-21 Release 0.3.4, I create one 20x20 matrix. I populate the diag with 1. I populate the off diags with .9. I then diagonalize. No problem. in order. Then, the next statements consist of creating a 16x16 matrix. I populate the diags with 1 and the off diags with .9. I then diagonalize. I get reverse order. Reverse order is better than random order, since I can just multiply the resulting matrices by an antidiag matrix of ones, but, it does point to some skepticism. Ordering shouldn't be a big deal, and, keep in mind that a lot of standard routines do not naturally order eigens.
 
User avatar
ametrano
Posts: 1
Joined: July 14th, 2002, 3:00 am

** Spectral Decomposition **

May 26th, 2004, 7:40 am

You're right: 0.3.4 doesn't order the eigens, 0.3.6 does, I don't remember about 0.3.5My suggestion: wait a couple of weeks and upgrade to the forthcoming 0.3.7 version.ciao -- Nando