/** * Generates a random value from the {@link WeibullDistribution Weibull Distribution}. * * @param shape the shape parameter of the Weibull distribution * @param scale the scale parameter of the Weibull distribution * @return random value sampled from the Weibull(shape, size) distribution * @throws NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. */ public double nextWeibull(double shape, double scale) throws NotStrictlyPositiveException { return new WeibullDistribution(getRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample(); }
/** * Instantiates a new Weibull pseudo random number generator. * * @param alpha the alpha * @param beta the beta */ public WeibullDistr(double alpha, double beta) { numGen = new WeibullDistribution(alpha, beta); }
/** * Instantiates a new Weibull pseudo random number generator. * * @param seed the seed * @param alpha the alpha * @param beta the beta */ public WeibullDistr(long seed, double alpha, double beta) { super(new WeibullDistribution(alpha, beta), seed); }
@Override public Object doWork(Object first, Object second) throws IOException{ if(null == first){ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory))); } if(null == second){ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory))); } Number shape = (Number)first; Number scale = (Number)second; return new WeibullDistribution(shape.doubleValue(), scale.doubleValue()); } }
@Override public Distribution get() { return new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max); } }
/** * Generates a random value from the {@link WeibullDistribution Weibull Distribution}. * * @param shape the shape parameter of the Weibull distribution * @param scale the scale parameter of the Weibull distribution * @return random value sampled from the Weibull(shape, size) distribution * @throws NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. */ public double nextWeibull(double shape, double scale) throws NotStrictlyPositiveException { return new WeibullDistribution(getRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample(); }
/** * @param param * shape * @param param2 * scale * @return Weibull distribution */ WeibullDistribution getWeibullDistribution(double param, double param2) { if (weibull == null || weibull.getShape() != param || weibull.getScale() != param2) { weibull = new WeibullDistribution(param, param2); } return weibull; }
@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 Distribution get() { return new DistributionQuantized(new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max), quantas); } }
/** * Generates a random value from the {@link WeibullDistribution Weibull Distribution}. * * @param shape the shape parameter of the Weibull distribution * @param scale the scale parameter of the Weibull distribution * @return random value sampled from the Weibull(shape, size) distribution * @throws NotStrictlyPositiveException if {@code shape <= 0} or * {@code scale <= 0}. */ public double nextWeibull(double shape, double scale) throws NotStrictlyPositiveException { return new WeibullDistribution(getRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample(); }
@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); } } }
public RealDistribution getRealDistribution(Context context) { RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator(); double e1 = getExpressions().get(0).evaluate(context); double e2 = getExpressions().get(1).evaluate(context); return new WeibullDistribution(randomGenerator, e1, e2); } };
public double evaluate(Context context) { RandomGenerator randomGenerator = RandomUtil.getInstance().getRandomGenerator(); double e1 = getExpressions().get(0).evaluate(context); double e2 = getExpressions().get(1).evaluate(context); return new WeibullDistribution(randomGenerator, e1, e2).sample(); }
int threadCount = 8; int maxQueued = 1024; final WeibullDistribution workTime = new WeibullDistribution(3, 200000); final long minWorkTime = TimeUnit.MICROSECONDS.toNanos(1); final long maxWorkTime = TimeUnit.MILLISECONDS.toNanos(1); workCount[i] = new WeibullDistribution(2, maxQueued); threadCount *= 2; maxQueued *= 2;
param1 = alpha; param2 = beta; sampler = new ContinuousSampler(new WeibullDistribution(alpha, beta)); break; case STUDENT:
return new UniformRealDistribution(node.get("lower").asDouble(), node.get("upper").asDouble()); case "WeibullDistribution": return new WeibullDistribution(node.get("alpha").asDouble(), node.get("beta").asDouble()); default: throw new RuntimeException("Unknown or not supported distribution: " + simpleName);
return new UniformRealDistribution(node.get("lower").asDouble(), node.get("upper").asDouble()); case "WeibullDistribution": return new WeibullDistribution(node.get("alpha").asDouble(), node.get("beta").asDouble()); case "LogUniformDistribution": return new LogUniformDistribution(node.get("min").asDouble(), node.get("max").asDouble());