Examples of WeibullDistribution


Examples of org.apache.commons.math3.distribution.WeibullDistribution

     * @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();
    }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

            {
                String[] bounds = params.get(0).split("\\.\\.+");
                final long min = Long.parseLong(bounds[0]);
                final long max = Long.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 _)
            {
                throw new IllegalArgumentException("Invalid parameter list for extreme (Weibull) distribution: " + params);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionOffsetApache(new WeibullDistribution(shape, scale), min, max);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

            {
                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);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

                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);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionQuantized(new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max), quantas);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

            {
                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 _)
            {
                throw new IllegalArgumentException("Invalid parameter list for extreme (Weibull) distribution: " + params);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionOffsetApache(new WeibullDistribution(new JDKRandomGenerator(), shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.WeibullDistribution

    private void testPromptnessOfExecution(long intervalNanos, float loadIncrement) throws InterruptedException, ExecutionException, TimeoutException
    {
        final int executorCount = 4;
        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);

        final int[] threadCounts = new int[executorCount];
        final WeibullDistribution[] workCount = new WeibullDistribution[executorCount];
        final ExecutorService[] executors = new ExecutorService[executorCount];
        for (int i = 0 ; i < executors.length ; i++)
        {
            executors[i] = JMXEnabledSharedExecutorPool.SHARED.newExecutor(threadCount, maxQueued, "test" + i, "test" + i);
            threadCounts[i] = threadCount;
            workCount[i] = new WeibullDistribution(2, maxQueued);
            threadCount *= 2;
            maxQueued *= 2;
        }

        long runs = 0;
        long events = 0;
        final TreeSet<Batch> pending = new TreeSet<>();
        final BitSet executorsWithWork = new BitSet(executorCount);
        long until = 0;
        // basic idea is to go through different levels of load on the executor service; initially is all small batches
        // (mostly within max queue size) of very short operations, moving to progressively larger batches
        // (beyond max queued size), and longer operations
        for (float multiplier = 0f ; multiplier < 2.01f ; )
        {
            if (System.nanoTime() > until)
            {
                System.out.println(String.format("Completed %.0fK batches with %.1fM events", runs * 0.001f, events * 0.000001f));
                events = 0;
                until = System.nanoTime() + intervalNanos;
                multiplier += loadIncrement;
                System.out.println(String.format("Running for %ds with load multiplier %.1f", TimeUnit.NANOSECONDS.toSeconds(intervalNanos), multiplier));
            }

            // wait a random amount of time so we submit new tasks in various stages of
            long timeout;
            if (pending.isEmpty()) timeout = 0;
            else if (Math.random() > 0.98) timeout = Long.MAX_VALUE;
            else if (pending.size() == executorCount) timeout = pending.first().timeout;
            else timeout = (long) (Math.random() * pending.last().timeout);

            while (!pending.isEmpty() && timeout > System.nanoTime())
            {
                Batch first = pending.first();
                boolean complete = false;
                try
                {
                    for (Result result : first.results.descendingSet())
                        result.future.get(timeout - System.nanoTime(), TimeUnit.NANOSECONDS);
                    complete = true;
                }
                catch (TimeoutException e)
                {
                }
                if (!complete && System.nanoTime() > first.timeout)
                {
                    for (Result result : first.results)
                        if (!result.future.isDone())
                            throw new AssertionError();
                    complete = true;
                }
                if (complete)
                {
                    pending.pollFirst();
                    executorsWithWork.clear(first.executorIndex);
                }
            }

            // if we've emptied the executors, give all our threads an opportunity to spin down
            if (timeout == Long.MAX_VALUE)
                Uninterruptibles.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);

            // submit a random batch to the first free executor service
            int executorIndex = executorsWithWork.nextClearBit(0);
            if (executorIndex >= executorCount)
                continue;
            executorsWithWork.set(executorIndex);
            ExecutorService executor = executors[executorIndex];
            TreeSet<Result> results = new TreeSet<>();
            int count = (int) (workCount[executorIndex].sample() * multiplier);
            long targetTotalElapsed = 0;
            long start = System.nanoTime();
            long baseTime;
            if (Math.random() > 0.5) baseTime = 2 * (long) (workTime.sample() * multiplier);
            else  baseTime = 0;
            for (int j = 0 ; j < count ; j++)
            {
                long time;
                if (baseTime == 0) time = (long) (workTime.sample() * multiplier);
                else time = (long) (baseTime * Math.random());
                if (time < minWorkTime)
                    time = minWorkTime;
                if (time > maxWorkTime)
                    time = maxWorkTime;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.