/src/main/java/net/finmath/montecarlo/assetderivativevaluation/products/LocalRiskMinimizingHedgePortfolio.java
final RandomVariable underlyingRebased = underlyingAtTimeNext.div( portfolioValue) ;
final RandomVariable underlyingRebased = underlyingAtTimeNext.div ( numeraireAtTimeNext ) ;
final RandomVariable productAtTime = productToHedge.getValue(time, modelUsedForHedging); final RandomVariable productAtTimeNext = productToHedge.getValue(timeNext, modelUsedForHedging); final RandomVariable[] basisFunctionsEstimator = getBasisFunctions(modelUsedForHedging.getAssetValue(time,0)); final RandomVariable[] basisFunctionsPredictor = getBasisFunctions(model.getAssetValue(time,0)); final MonteCarloConditionalExpectationRegression condExpectationHedging = new MonteCarloConditionalExpectationRegression(basisFunctionsEstimator, basisFunctionsEstimator); final MonteCarloConditionalExpectationRegression condExpectationValuation = new MonteCarloConditionalExpectationRegression(basisFunctionsEstimator, basisFunctionsPredictor); <extra_id_0> final RandomVariable underlyingRebasedExpected = condExpectationHedging.getConditionalExpectation(underlyingRebased); final RandomVariable underlyingRebasedMartingale = underlyingRebased.sub(underlyingRebasedExpected); final RandomVariable derivativeRebased = productAtTimeNext.div(numeraireAtTimeNext); final RandomVariable derivativeRebasedExpected = condExpectationHedging.getConditionalExpectation(derivativeRebased); final RandomVariable derivativeRebasedMartingale = derivativeRebased.sub(derivativeRebasedExpected); final RandomVariable derivativeTimesUnderlying = derivativeRebasedMartingale.mult(underlyingRebasedMartingale);