类org.apache.commons.math3.distribution.WeibullDistribution源码实例Demo

下面列出了怎么用org.apache.commons.math3.distribution.WeibullDistribution的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gama   文件: Random.java
@operator (
		value = "weibull_rnd",
		can_be_const = false,
		category = { IOperatorCategory.RANDOM },
		concept = { IConcept.RANDOM })
@doc (
		value = "returns a random value from a Weibull distribution with specified values of the shape (alpha) and scale (beta) parameters. See https://mathworld.wolfram.com/WeibullDistribution.html for more details (equations 1 and 2). ",
		examples = { @example (
				value = "weibull_rnd(2,3) ",
				equals = "0.731",
				test = false) },
		see = { "binomial", "gamma_rnd", "gauss_rnd", "lognormal_rnd", "poisson", "rnd", "skew_gauss",
				"truncated_gauss", "weibull_trunc_rnd" })
@no_test (Reason.IMPOSSIBLE_TO_TEST)
public static Double OpWeibullDist(final IScope scope, final Double shape, final Double scale)
		throws GamaRuntimeException {
	final WeibullDistribution dist = new WeibullDistribution(scope.getRandom().getGenerator(), shape, scale);

	return dist.sample();
}
 
源代码2 项目: gama   文件: Random.java
@operator (
		value = "weibull_density",
		can_be_const = false,
		category = { IOperatorCategory.RANDOM },
		concept = { IConcept.RANDOM })
@doc (
		value = "weibull_density(x,shape,scale) returns the probability density function (PDF) at the specified point x "
				+ "of the Weibull distribution with the given shape and scale.",
		examples = { @example ( value = "weibull_rnd(1,2,3) ", equals = "0.731", test = false) },
		see = { "binomial", "gamma_rnd", "gauss_rnd", "lognormal_rnd", "poisson", "rnd", "skew_gauss",
				"lognormal_density", "gamma_density"})
@no_test (Reason.IMPOSSIBLE_TO_TEST)
public static Double OpWeibullDistDensity(final IScope scope, final Double x, final Double shape, final Double scale)
		throws GamaRuntimeException {
	final WeibullDistribution dist = new WeibullDistribution(scope.getRandom().getGenerator(), shape, scale);

	return dist.density(x);
}
 
源代码3 项目: stratio-cassandra   文件: OptionDistribution.java
@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]);
        if (min == max)
            return new FixedFactory(min);
        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 ignore)
    {
        throw new IllegalArgumentException("Invalid parameter list for extreme (Weibull) distribution: " + params);
    }
}
 
源代码4 项目: stratio-cassandra   文件: OptionDistribution.java
@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)));
        if (min == max)
            return new FixedFactory(min);
        return new QuantizedExtremeFactory(min, max, shape, scale, quantas);
    } catch (Exception ignore)
    {
        throw new IllegalArgumentException("Invalid parameter list for quantized extreme (Weibull) distribution: " + params);
    }
}
 
@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());
}
 
源代码6 项目: astor   文件: RandomDataGeneratorTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码7 项目: astor   文件: RandomDataTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码8 项目: astor   文件: RandomDataTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码9 项目: astor   文件: RandomDataGeneratorTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码10 项目: astor   文件: RandomDataTest.java
@Test
public void testNextWeibull() throws Exception {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码11 项目: astor   文件: RandomDataGeneratorTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码12 项目: astor   文件: RandomDataGeneratorTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码13 项目: astor   文件: RandomDataGeneratorTest.java
@Test
public void testNextWeibull() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextWeibull(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
源代码14 项目: stratio-cassandra   文件: OptionDistribution.java
@Override
public Distribution get()
{
    return new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max);
}
 
源代码15 项目: stratio-cassandra   文件: OptionDistribution.java
@Override
public Distribution get()
{
    return new DistributionQuantized(new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max), quantas);
}
 
源代码16 项目: astor   文件: RandomDataGenerator.java
/**
 * 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();
}
 
源代码17 项目: astor   文件: RandomDataGenerator.java
/**
 * 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(getRan(), shape, scale,
            WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}
 
源代码18 项目: astor   文件: RandomDataImpl.java
/**
 * Generates a random value from the {@link WeibullDistribution Weibull Distribution}.
 * This implementation uses {@link #nextInversionDeviate(RealDistribution) inversion}
 * to generate random values.
 *
 * @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
 * @since 2.2
 */
public double nextWeibull(double shape, double scale) {
    return nextInversionDeviate(new WeibullDistribution(shape, scale));
}
 
源代码19 项目: astor   文件: RandomDataGenerator.java
/**
 * 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();
}
 
源代码20 项目: astor   文件: RandomDataImpl.java
/**
 * Generates a random value from the {@link WeibullDistribution Weibull Distribution}.
 * This implementation uses {@link #nextInversionDeviate(RealDistribution) inversion}
 * to generate random values.
 *
 * @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
 * @since 2.2
 */
public double nextWeibull(double shape, double scale) {
    return nextInversionDeviate(new WeibullDistribution(shape, scale));
}
 
源代码21 项目: astor   文件: RandomDataGenerator.java
/**
 * 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();
}
 
源代码22 项目: astor   文件: RandomDataGenerator.java
/**
 * 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();
}
 
源代码23 项目: astor   文件: RandomDataGenerator.java
/**
 * 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();
}
 
 类方法
 同包方法