net.finmath.montecarlo.interestrate.modelplugins.LIBORCovarianceModelFromVolatilityAndCorrelation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of finmath-lib Show documentation
Show all versions of finmath-lib Show documentation
finmath lib is a Mathematical Finance Library in Java.
It provides algorithms and methodologies related to mathematical finance.
/*
* (c) Copyright Christian P. Fries, Germany. Contact: [email protected].
*
* Created on 15.12.2007
*/
package net.finmath.montecarlo.interestrate.modelplugins;
import java.util.Arrays;
import net.finmath.stochastic.RandomVariableInterface;
import net.finmath.time.TimeDiscretizationInterface;
/**
* A covariance model build from a volatility model implementing
* LIBORVolatilityModel
and a correlation model
* implementing LIBORCorrelationModel
.
*
*
* The model parameters are given by the concatenation of the
* parameters of the LIBORVolatilityModel
and
* the parameters of the LIBORCorrelationModel
,
* in this ordering
*
*
* @author Christian Fries
*/
public class LIBORCovarianceModelFromVolatilityAndCorrelation extends AbstractLIBORCovarianceModelParametric {
private static final long serialVersionUID = -2194221041462041686L;
private LIBORVolatilityModel volatilityModel;
private LIBORCorrelationModel correlationModel;
public LIBORCovarianceModelFromVolatilityAndCorrelation(TimeDiscretizationInterface timeDiscretization, TimeDiscretizationInterface liborPeriodDiscretization, LIBORVolatilityModel volatilityModel, LIBORCorrelationModel correlationModel) {
super(timeDiscretization, liborPeriodDiscretization, correlationModel.getNumberOfFactors());
this.volatilityModel = volatilityModel;
this.correlationModel = correlationModel;
}
@Override
public RandomVariableInterface[] getFactorLoading(int timeIndex, int component, RandomVariableInterface[] realizationAtTimeIndex) {
RandomVariableInterface[] factorLoading = new RandomVariableInterface[correlationModel.getNumberOfFactors()];
RandomVariableInterface volatility = volatilityModel.getVolatility(timeIndex, component);
for (int factorIndex = 0; factorIndex < factorLoading.length; factorIndex++) {
factorLoading[factorIndex] = volatility.mult(correlationModel.getFactorLoading(timeIndex, factorIndex, component));
}
return factorLoading;
}
@Override
public RandomVariableInterface getFactorLoadingPseudoInverse(int timeIndex, int component, int factor, RandomVariableInterface[] realizationAtTimeIndex) {
// Note that we assume that the correlation model getFactorLoading gives orthonormal vectors
RandomVariableInterface factorLoadingPseudoInverse = volatilityModel.getVolatility(timeIndex, component).invert()
.mult(correlationModel.getFactorLoading(timeIndex, factor, component));
// @todo numberOfComponents should be stored as a member?!
int numberOfComponents = getLiborPeriodDiscretization().getNumberOfTimeSteps();
double factorWeight = 0.0;
for(int componentIndex=0; componentIndex
© 2015 - 2025 Weber Informatics LLC | Privacy Policy