@Override public DistributionFactory getFactory(List<String> params) { if (params.size() != 3) throw new IllegalArgumentException("Invalid parameter list for quantized extreme (Weibull) distribution: " + params); try { String[] bounds = params.get(0).split("\\.\\.+"); final long min = parseLong(bounds[0]); final long max = parseLong(bounds[1]); final double shape = Double.parseDouble(params.get(1)); final int quantas = Integer.parseInt(params.get(2)); WeibullDistribution findBounds = new WeibullDistribution(shape, 1d); // max probability should be roughly equal to accuracy of (max-min) to ensure all values are visitable, // over entire range, but this results in overly skewed distribution, so take sqrt final double scale = (max - min) / findBounds.inverseCumulativeProbability(1d - Math.sqrt(1d / (max - min))); return new QuantizedExtremeFactory(min, max, shape, scale, quantas); } catch (Exception e) { throw new IllegalArgumentException("Invalid parameter list for quantized extreme (Weibull) distribution: " + params); } } }
@Override public DistributionFactory getFactory(List<String> params) { if (params.size() != 2) throw new IllegalArgumentException("Invalid parameter list for extreme (Weibull) distribution: " + params); try { String[] bounds = params.get(0).split("\\.\\.+"); final long min = parseLong(bounds[0]); final long max = parseLong(bounds[1]); final double shape = Double.parseDouble(params.get(1)); WeibullDistribution findBounds = new WeibullDistribution(shape, 1d); // max probability should be roughly equal to accuracy of (max-min) to ensure all values are visitable, // over entire range, but this results in overly skewed distribution, so take sqrt final double scale = (max - min) / findBounds.inverseCumulativeProbability(1d - Math.sqrt(1d / (max - min))); return new ExtremeFactory(min, max, shape, scale); } catch (Exception e) { throw new IllegalArgumentException("Invalid parameter list for extreme (Weibull) distribution: " + params); } } }
@Override public final void compute() { if (input[0].isDefined() && input[1].isDefined() && input[2].isDefined()) { double param = a.getDouble(); double param2 = b.getDouble(); double val = c.getDouble(); try { WeibullDistribution dist = getWeibullDistribution(param, param2); num.setValue(dist.inverseCumulativeProbability(val)); } catch (Exception e) { num.setUndefined(); } } else { num.setUndefined(); } }