net.finmath.montecarlo.CorrelatedBrownianMotion Maven / Gradle / Ivy
/*
* (c) Copyright Christian P. Fries, Germany. Contact: [email protected].
*
* Created on 25.05.2013
*/
package net.finmath.montecarlo;
import net.finmath.stochastic.RandomVariable;
import net.finmath.time.TimeDiscretization;
/**
* Provides a correlated Brownian motion from given (independent) increments
* and a given matrix of factor loadings.
*
* The i-th factor of this BrownianMotionLazyInit is dWi where
* dWi = fi,1 dU1 + ... + fi,m dUm
* for i = 1, ..., n.
*
* Here fi,j are the factor loadings, an n × m-matrix.
*
* If dUj are independent, then dWi dWk = ρi,k dt
* where ρi,k = fi · fj.
*
* Note: It is possible to create this class with a Brownian motion U which is
* already correlated. The factors loadings will be applied accordingly.
*
* @author Christian Fries
* @version 1.0
*/
public class CorrelatedBrownianMotion implements BrownianMotion {
private final BrownianMotion uncollelatedFactors;
private final double[][] factorLoadings;
/**
* Create a correlated Brownian motion from given independent increments
* and a given matrix of factor loadings.
*
* The i-th factor of this BrownianMotionLazyInit is dWi where
* dWi = fi,1 dU1 + ... + fi,m dUm
* for i = 1, ..., n.
*
* Here fi,j are the factor loadings, an n × m-matrix.
*
* If dUj are independent, then dWi dWk = ρi,k dt
* where ρi,k = fi · fj.
*
* @param uncollelatedFactors The Brownian motion providing the (uncorrelated) factors dUj.
* @param factorLoadings The factor loadings fi,j.
*/
public CorrelatedBrownianMotion(final BrownianMotion uncollelatedFactors,
final double[][] factorLoadings) {
super();
this.uncollelatedFactors = uncollelatedFactors;
this.factorLoadings = factorLoadings;
}
/* (non-Javadoc)
* @see net.finmath.montecarlo.BrownianMotion#getBrownianIncrement(int, int)
*/
@Override
public RandomVariable getBrownianIncrement(final int timeIndex, final int factor) {
RandomVariable brownianIncrement = new RandomVariableFromDoubleArray(0.0);
for(int factorIndex=0; factorIndex