public RandomVariable [ ] getBasisFunctions ( double fixingDate , LIBORModelMonteCarloSimulationModel model ) throws CalculationException { ArrayList < RandomVariable > basisFunctions = new ArrayList <> ( ) ; // Constant RandomVariable basisFunction = new RandomVariableFromDoubleArray ( 1.0 ) ; //.getRandomVariableForConstant(1.0); basisFunctions . add ( basisFunction ) ; int fixingDateIndex = Arrays . binarySearch ( fixingDates , fixingDate ) ; if ( fixingDateIndex < 0 ) { fixingDateIndex = - fixingDateIndex ; } if ( fixingDateIndex >= fixingDates . length ) { fixingDateIndex = fixingDates . length - 1 ; } // forward rate to the next period RandomVariable rateShort = model . getLIBOR ( fixingDate , fixingDate , paymentDates [ fixingDateIndex ] ) ; RandomVariable discountShort = rateShort . mult ( paymentDates [ fixingDateIndex ] - fixingDate ) . add ( 1.0 ) . invert ( ) ; basisFunctions . add ( discountShort ) ; basisFunctions . add ( discountShort . pow ( 2.0 ) ) ; // basisFunctions.add(rateShort.pow(3.0)); // forward rate to the end of the product RandomVariable rateLong = model . getLIBOR ( fixingDate , fixingDates [ fixingDateIndex ] , paymentDates [ paymentDates . length - 1 ] ) ; RandomVariable discountLong = rateLong . mult ( paymentDates [ paymentDates . length - 1 ] - fixingDates [ fixingDateIndex ] ) . add ( 1.0 ) . invert ( ) ; basisFunctions . add ( discountLong ) ; basisFunctions . add ( discountLong . pow ( 2.0 ) ) ; // basisFunctions.add(rateLong.pow(3.0)); // Numeraire RandomVariable numeraire = model . getNumeraire ( fixingDate ) . invert ( ) ; basisFunctions . add ( numeraire ) ; // basisFunctions.add(numeraire.pow(2.0)); // basisFunctions.add(numeraire.pow(3.0)); return basisFunctions . toArray ( new RandomVariable [ basisFunctions . size ( ) ] ) ; }
Return the basis functions for the regression suitable for this product .