Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

LowFactorDriftlessLMM.h

Go to the documentation of this file.
00001 /* WARANTY NOTICE AND COPYRIGHT
00002 This program is free software; you can redistribute it and/or
00003 modify it under the terms of the GNU General Public License
00004 as published by the Free Software Foundation; either version 2
00005 of the License, or (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program; if not, write to the Free Software
00014 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00015 
00016 Copyright (C) Michael J. Meyer
00017 
00018 matmjm@mindspring.com
00019 spyqqqdia@yahoo.com
00020 
00021 */
00022 
00023 
00024 #ifndef martingale_lowfactordriftlesslmm_h    
00025 #define martingale_lowfactordriftlesslmm_h
00026 
00027 #include "TypedefsMacros.h"
00028 #include "LiborMarketModel.h"                // base class
00029 #include "Matrix.h"                          // direct members
00030 
00031 MTGL_BEGIN_NAMESPACE(Martingale)
00032 
00033 
00034 
00035 // dependencies
00036 class std::ostream;
00037 class UTRMatrixSequence;
00038 class StochasticGenerator;       // StochasticGenerator.h
00039 class SobolLiborDriver;
00040 class MonteCarloLiborDriver;
00041 class LiborFactorLoading;        // LiborFactorLoading.h
00042 
00043 
00044 
00045 
00054 /*******************************************************************************
00055  *
00056  *                                 LowFactorDriftlessLMM
00057  *
00058  ******************************************************************************/ 
00059 
00067 class LowFactorDriftlessLMM : public LiborMarketModel {
00068         
00069         
00070         int r;    // number of factors (rank to which covariation matrices are reduced).
00071 
00072         
00073         // n-1 by r matrix of standard normal increments.
00074         // Row t is used to drive the time step T_t->T_{t+1}
00075         RealMatrix Z;
00076     
00077     // Array containing the X-Libors X(t,j)=X_j(T_t)=delta_jL_j(T_t), t<=j.
00078     // The rows are the vectors X(T_t)=(X_t(T_t),...,X_{n-1}(T_t)).
00079     UTRRealMatrix U;
00080     
00081     // Array containing the log-Libors Y(t,j)=Y_j(T_t)=log(X_j(T_t)), t<=j.
00082     // The rows are the vectors Y(T_t)=(Y_t(T_t),...,Y_{n-1}(T_t)).
00083     UTRRealMatrix Y;
00084         
00085         // accrual factors H(t,j)=H_j(T_t)=B_j(T_t)/B_n(T_t), t<=j.
00086         // we take this up to j=n where H(t,n)=1 to avoid messy code.
00087         UTRRealMatrix H;         
00088  
00089         
00090         // Array containing the deterministic drift steps
00091     // m(t,j)=-0.5*integral_{T_t}^{T_{t+1}}sigma^2_j(s)ds of the log(U_j).
00092     UTRRealMatrix m;
00093     
00094     // volatility step vector
00095     RealArray1D V;
00096     
00097  
00098     // the log(U_j) covariation matrices of the needed for the time steps
00099     UTRMatrixSequence logLiborCovariationMatrices;
00100                 
00101     // the upper triangular roots of the above covariation matrices
00102     MatrixSequence lowRankCovariationMatrixRoots;
00103         
00104         
00105     StochasticGenerator* SG;    // generates the Wiener increments driving the paths     
00106         
00107         RealVector XVec;          // cache for fast returning of X-Libor vectors.
00108   
00109 
00110 public:
00111 
00114     void switchToQMC();
00115         
00116         
00119     void switchToMC();
00120 
00121         
00122 // FACTOR ANALYSIS
00123         
00128    void factorizationTest() const;
00129 
00130 
00131 // LIBORS
00132 
00133 
00139      Real XL(int j, int t) const;
00140          
00141          
00148       const RealVector& XLvect(int t, int p);
00149                  
00150 
00151         
00152 //  CONSTRUCTOR
00153 
00154     
00161     LowFactorDriftlessLMM(LiborFactorLoading* fl, int r);
00162         
00163         
00171         static LiborMarketModel* sample(int n, int volType, int corrType, int r=3);
00172     
00173 
00174 // WIENER INCREMENTS
00175 
00180     void newWienerIncrements(int t);    
00181         
00185         void printWienerIncrements(int t, int s) const;
00186         
00187         
00197         int effectiveDimension(int t, int s) const { return (s-t)*r; }
00198 
00199 
00200                 
00201                 
00202 // TIME STEP
00203 
00204     
00205 
00214      void timeStep(int t, int p);
00215                 
00216      
00223      void timeStep(int t){ timeStep(t,t+1); }
00224      
00225          
00226 
00227 //  OVERRIDE lIBOR VOLATLTIES    
00228 //  FASTER VERSIONS OF BONDS, SWAPRATES,...
00229      
00230 
00235      Real vol(int i) const;
00236          
00237      
00238 
00239 
00240 // FORWARD TRANSPORTING FACTORS
00241          
00242          
00243                  
00247      Real H_i0(int i) const;
00248      
00249 
00259      Real H_it(int i, int t);
00260 
00261 
00262      
00268      Real H_ii(int i) const;
00269          
00270          
00277      Real H_pq(int p, int q, int t);
00278 
00279 
00280  
00281          
00282               
00283 // ZERO COUPON BONDS 
00284 
00285 
00290      Real B0(int i) const;
00291 
00292  
00300     Real B(int i, int t);
00301 
00302         
00303 
00304      
00305 
00306          
00307 // FORWARD SWAP RATES                      
00308              
00309 
00310      
00318      Real swapRate(int p, int q, int t);
00319 
00320 
00325      Real swapRate(int p, int q) { return swapRate(p,q,0); } 
00326 
00327  
00328          
00329          
00330 // ANNUITY NUMERAIRE
00331                   
00332      
00333      
00340      Real B_pq(int p, int q, int t);
00341 
00342      
00348      Real B_pq(int p, int q) { return B_pq(p,q,0); }
00349          
00350          
00351          
00352 // SWAPTION AND CAPLET AGGREGATE VOLATILITIES (SIGMA)
00353          
00362      Real capletAggregateVolatility(int i) const;
00363          
00364          
00374      Real swaptionAggregateVolatility(int p, int q, int t) const;
00375 
00376 
00384      Real bondAggregateVolatility(Bond* B, int t) const;
00385 
00386 
00387          
00388 // STRING MESSAGE
00389     
00390     
00393     std::ostream& printSelf(std::ostream& os) const;
00394          
00395          
00396              
00397 
00398 
00399 }; // end DriftlessLMM
00400 
00401 
00402 
00403 MTGL_END_NAMESPACE(Martingale)  
00404 
00405 #endif
00406 
00407 

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3