📄 lmm_parameters.java
字号:
/* WARANTY NOTICE AND COPYRIGHTThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.Copyright (C) Michael J. Meyermatmjm@mindspring.comspyqqqdia@yahoo.com*//* * LMM_Parameters.java * * Created on August 30, 2002, 8:58 AM */package Libor.LiborProcess;import LinAlg.*;/** <p>Class which combines an initial term structure <code>l[j]=L_j(0)</code> * with a <code>FactorLoading</code> object and hence provides everything * to set up a Libor process.</p> * * <p>Used to control the Libor process set up. Different constructors might * return sample set ups, intiate user interaction to get parameter input * or choose between different volatility and correlation structures.</p> * * @author Michael J. Meyer */public class LMM_Parameters { double[] l; // intial term structure FactorLoading factorLoading; // volatility and correlation structure /** Flag identifying the type of Libor model setup * (Coffey-Shoenmakers correlation, uses <code>CS_FactorLoading</code>). */ public static final int CS=0; // Coffey-Shoenmakers, CS_FactorLoading /** Flag identifying the type of Libor model setup * (exponential power correlation, uses <code>EP_FactorLoading</code>). */ public static final int EP=1; /** Flag identifying the type of Libor model setup * (Jaeckel-Rebonato correlation, uses <code>JR_FactorLoading</code>). */ public static final int JR=2; /******************************************************************************* * * CONSTRUCTORS * ******************************************************************************/ /** <p>Constructs an LMM parameter sample drawn from the specified model type. * Used to quickly instantiate a Libor process for experimentation. * Initial term structure is <code>L_j(0)=0.04, j=0,...,n-1.</code> * If the <code>modelType</code> parameter is not recognized a * <code>CS_FactorLoading</code> is used as a default. * * @param n dimension of Libor process. * @param modelType flag identifying the type of factor loading, choose * from <code>CS, EP</code>. */ public LMM_Parameters(int n, int modelType) { l=new double[n]; for(int i=0;i<n;i++)l[i]=0.04; switch(modelType){ case EP: factorLoading=EP_FactorLoading.sample(n); break; case JR: factorLoading=JR_FactorLoading.sample(n); break; default: factorLoading=CS_FactorLoading.sample(n); } // end switch } // end constructor /** <p>Constructs an LMM parameter object from an initial term structure * <code>l[i]=L_i(0)</code> and <code>FactorLoading fl</code>.</p> * * @param l initial term structure <code>l[i]=L_i(0)</code>. * @param fl the <code>FactorLoading</code>. */ public LMM_Parameters(double[] l, FactorLoading fl) { this.l=l; factorLoading=fl; } // end constructor /******************************************************************************* * * ACCESSORS * ******************************************************************************/ /** The array <code>l[j]=L_j(0), j<n.</code> */ public double[] initialTermStructure(){ return l; } /** The volatility and correlation structure. */ public FactorLoading factorLoading(){ return factorLoading; } /******************************************************************************* * * toString * ******************************************************************************/ /** A message containing all the parameters, initial Libors. */ public String toString() { String factLoading, initialLibors; initialLibors="\n\nInitial Libors: "+new ColtVector(l).toString(); factLoading=factorLoading.toString(); return initialLibors+factLoading; } } // end LMM_parameters
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -