/* (non-Javadoc)
@see net.finmath.stochastic.RandomVariable#getQuantile(double, net.finmath.stochastic.RandomVariable)
504761
@Override
	public double getQuantile(double quantile, RandomVariable probabilities) {
		return ((RandomVariableAAD) getRandomVariableInterface()).getRandomVariableInterface().getQuantile(quantile, probabilities);
	}
704789
public Double getDouble (int index) {
        String string = getString (index);
        return (string != null) ? Double.parseDouble (string) : null;
    }
1327206
public static Double getDouble(ValueData valueData) throws RepositoryException
   {
      if (valueData instanceof TransientValueData)
      {
         return getDouble(((TransientValueData)valueData).delegate);
      }

      return ((AbstractValueData)valueData).getDouble();
   }
1138198
protected double estimateQuantile(Bucket bucket, double expectedCount, double lastCount) {
		return bucket.getMin() + (bucket.getMax() - bucket.getMin()) * Math.exp(Math.log(expectedCount - lastCount) / Math.log(bucket.getCount()));
	}
505318
public double getDouble(String columnName, double defaultValue) {
        int index = getColumnIndex(columnName);
        if (isValidIndex(index)) {
            return getDouble(index);
        } else {
            return defaultValue;
        }
    }
764340
private Double getDouble(Number number)
   {
      Double result = null;

      if (number != null)
      {
         result = Double.valueOf(number.doubleValue());
      }

      return result;
   }
114419
@Override
	public RandomVariable pow(double exponent) {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return FastMath.pow(x, exponent);
			}
		});
	}
923539
public double getDouble(String key, double defaultValue) {
    String value = get(key);
    return value == null ? defaultValue : Double.parseDouble(value);
  }
180012
public static Double readDouble(String value, Double defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Double.valueOf(value);
	}
1352660
@CheckForNull
  public Double getDouble(String key) {
    String value = getString(key);
    if (StringUtils.isNotEmpty(value)) {
      try {
        return Double.valueOf(value);
      } catch (NumberFormatException e) {
        throw new IllegalStateException(String.format("The property '%s' is not a double value", key));
      }
    }
    return null;
  }
162519
@Override
	public RandomVariable mult(double value) {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return x * value;
			}
		});
	}
967600
public double getDouble(int index)
    {
        checkIndexLength(index, SizeOf.SIZE_OF_DOUBLE);
        return unsafe.getDouble(base, address + index);
    }
1338314
public static double getRandomDouble(double min, double max) {
		Random r = new Random();
		return min + (max - min) * r.nextDouble();
	}
1077753
@Override
	public double getQuantileExpectation(double quantileStart, double quantileEnd) {
		if(isDeterministic()) {
			return valueIfNonStochastic;
		}
		if(size() == 0) {
			return Double.NaN;
		}
		if(quantileStart > quantileEnd) {
			return getQuantileExpectation(quantileEnd, quantileStart);
		}

		float[] realizationsSorted = realizations.clone();
		java.util.Arrays.sort(realizationsSorted);

		int indexOfQuantileValueStart	= Math.min(Math.max((int)Math.round((size()+1) * quantileStart - 1), 0), size()-1);
		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];
		}
		quantileExpectation /= indexOfQuantileValueEnd-indexOfQuantileValueStart+1;

		return quantileExpectation;
	}
1223374
public double getDouble(int columnIndex) {
		Object fieldValue = data[columnIndex];
		if (fieldValue == null) {
			return 0.0;
		}
		if (fieldValue instanceof Number) {
			return ((Number) fieldValue).doubleValue();
		}
		throw new DBFException("Unsupported type for Number at column:" + columnIndex + " "
				+ fieldValue.getClass().getCanonicalName());
	}
468106
@Override
	public RandomVariable cap(double cap) {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return Math.min(x, cap);
			}
		});
	}
726065
@Override
	public RandomVariable squared() {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return x * x;
			}
		});
	}