Fixed NPE for basis functions derived from deterministic random variable
@@ -168,6 +168,10 @@ public class DeltaHedgedPortfolioWithAAD extends AbstractAssetMonteCarloProduct
private ArrayList<RandomVariable> getRegressionBasisFunctionsBinning(RandomVariable underlying, RandomVariable indicator) {
ArrayList<RandomVariable> basisFunctions = new ArrayList<RandomVariable>();
+ if(underlying.isDeterministic()) {
+ basisFunctions.add(underlying);
+ }
+ else {
int numberOfBins = 20;
double[] values = underlying.getRealizations();
Arrays.sort(values);
@@ -176,6 +180,7 @@ public class DeltaHedgedPortfolioWithAAD extends AbstractAssetMonteCarloProduct
RandomVariable basisFunction = underlying.sub(binLeft).choose(new RandomVariableFromDoubleArray(1.0), new RandomVariableFromDoubleArray(0.0)).mult(indicator);
basisFunctions.add(basisFunction);
}
+ }
return basisFunctions;
}
