/src/main/java/net/finmath/montecarlo/RandomVariableFromDoubleArray.java
final double[] realisationsSorted = realizations.clone( ) ;
final double[] realizationsSorted = realizations.clone ( ) ;
if(size() == 0) { return Double.NaN; } if(quantileStart > quantileEnd) { return getQuantileExpectation(quantileEnd, quantileStart); } <extra_id_0> java.util.Arrays.sort(realizationsSorted); final int indexOfQuantileValueStart = Math.min(Math.max((int)Math.round((size()+1) * quantileStart - 1), 0), size()-1); final int indexOfQuantileValueEnd = Math.min(Math.max((int)Math.round((size()+1) * quantileEnd - 1), 0), size()-1); double quantileExpectation = 0.0; for (int i=indexOfQuantileValueStart; i<=indexOfQuantileValueEnd;i++) { quantileExpectation += realizationsSorted[i];