public override double?apply(double?x) { ArgChecker.notNull(x, "x"); ArgChecker.notNegative(x, "x"); if (DoubleMath.fuzzyEquals(x, 0.5, 1e-14)) { return(0.5); } return(_dist.getInverseCDF(x.Value)); }
/// <summary> /// Creates an instance. /// </summary> /// <param name="a"> the value </param> /// <param name="maxIter"> the maximum iterations </param> /// <param name="eps"> the epsilon </param> public IncompleteGammaFunction(double a, int maxIter, double eps) { ArgChecker.notNegativeOrZero(a, "a"); ArgChecker.notNegative(eps, "eps"); if (maxIter < 1) { throw new System.ArgumentException("Must have at least one iteration"); } _maxIter = maxIter; _eps = eps; _a = a; }
//------------------------------------------------------------------------- /// <summary> /// Parses the quantity. /// </summary> /// <param name="row"> the CSV row to parse </param> /// <returns> the quantity, long first, short second </returns> /// <exception cref="IllegalArgumentException"> if the row cannot be parsed </exception> public static DoublesPair parseQuantity(CsvRow row) { double?quantityOpt = row.findValue(QUANTITY_FIELD).map(s => LoaderUtils.parseDouble(s)); if (quantityOpt.HasValue) { double quantity = quantityOpt.Value; return(DoublesPair.of(quantity >= 0 ? quantity : 0, quantity >= 0 ? 0 : -quantity)); } double?longQuantityOpt = row.findValue(LONG_QUANTITY_FIELD).map(s => LoaderUtils.parseDouble(s)); double?shortQuantityOpt = row.findValue(SHORT_QUANTITY_FIELD).map(s => LoaderUtils.parseDouble(s)); if (!longQuantityOpt.HasValue && !shortQuantityOpt.HasValue) { throw new System.ArgumentException(Messages.format("Security must contain a quantity column, either '{}' or '{}' and '{}'", QUANTITY_FIELD, LONG_QUANTITY_FIELD, SHORT_QUANTITY_FIELD)); } double longQuantity = ArgChecker.notNegative(longQuantityOpt.GetValueOrDefault(0d), LONG_QUANTITY_FIELD); double shortQuantity = ArgChecker.notNegative(shortQuantityOpt.GetValueOrDefault(0d), SHORT_QUANTITY_FIELD); return(DoublesPair.of(longQuantity, shortQuantity)); }
public override double?apply(double?x) { ArgChecker.notNull(x, "x"); ArgChecker.notNegative(x, "x"); return(_calc.apply(0.5 + 0.5 * x)); }
public StudentTTwoTailedCriticalValueCalculator(double nu, RandomEngine engine) { ArgChecker.notNegative(nu, "nu"); ArgChecker.notNull(engine, "engine"); _calc = new StudentTOneTailedCriticalValueCalculator(nu, engine); }
public StudentTTwoTailedCriticalValueCalculator(double nu) { ArgChecker.notNegative(nu, "nu"); _calc = new StudentTOneTailedCriticalValueCalculator(nu); }
public StudentTOneTailedCriticalValueCalculator(double nu) { ArgChecker.notNegative(nu, "nu"); _dist = new StudentTDistribution(nu); }