Search in sources :

Example 11 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project jackrabbit-oak by apache.

the class MicroBenchmark method runTest.

private static DescriptiveStatistics runTest(Benchmark benchmark) throws Exception {
    final DescriptiveStatistics statistics = new DescriptiveStatistics();
    long runtimeEnd = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60);
    while (System.currentTimeMillis() < runtimeEnd) {
        statistics.addValue(execute(benchmark));
    }
    return statistics;
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 12 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project MPW by shineangelic.

the class BlocksActivity method doApacheMath.

private SummaryStatistics doApacheMath(List<Matured> maturi) {
    ArrayList<Matured> revElements = new ArrayList<>(maturi);
    Collections.reverse(revElements);
    long[] intervals = new long[maturi.size()];
    Date prevDate = revElements.get(0).getTimestamp();
    int i = 0;
    // parto da 1 a calcolare il 1o intervallo
    for (int t = 1; t < revElements.size(); t++) {
        Date curDate = revElements.get(t).getTimestamp();
        intervals[i++] = curDate.getTime() - prevDate.getTime();
        prevDate = curDate;
    }
    // a oggi, calcolo ultimo intervallo aperto
    intervals[maturi.size() - 1] = (new Date().getTime() - revElements.get(maturi.size() - 1).getTimestamp().getTime());
    // Get a DescriptiveStatistics instance
    SummaryStatistics stats = new SummaryStatistics();
    // Add the data from the array
    for (int im = 0; im < intervals.length; im++) {
        stats.addValue(intervals[im]);
    }
    return stats;
}
Also used : Matured(it.angelic.mpw.model.jsonpojos.blocks.Matured) ArrayList(java.util.ArrayList) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) Date(java.util.Date)

Example 13 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project narchy by automenta.

the class Focus method update.

protected void update(NAR nar) {
    if (!updating.compareAndSet(false, true))
        return;
    try {
        int n = choice.size();
        if (n == 0)
            return;
        if (sliceIters.length != n) {
            // weight = new float[n];
            time = new DescriptiveStatistics[n];
            timeMean = new double[n];
            done = new DescriptiveStatistics[n];
            for (int i = 0; i < n; i++) {
                time[i] = new DescriptiveStatistics(WINDOW);
                done[i] = new DescriptiveStatistics(WINDOW);
            }
            // assert (n < 32) : "TODO make atomic n>32 bitset";
            value = new float[n];
            doneMean = new double[n];
            doneMax = new long[n];
            // last
            sliceIters = new int[n];
        }
        revaluator.update(nar);
        double jiffy = nar.loop.jiffy.floatValue();
        double throttle = nar.loop.throttle.floatValue();
        // / (n / concurrency);
        timesliceNS = nar.loop.periodNS() * jiffy * throttle;
        for (int i = 0; i < n; i++) {
            Causable c = choice.get(i);
            if (c == null)
                // ?
                continue;
            c.can.commit(commiter);
            long timeNS = committed[0];
            if (timeNS > 0) {
                DescriptiveStatistics t = this.time[i];
                t.addValue(timeNS);
                double timeMeanNS = this.timeMean[i] = t.getMean();
                DescriptiveStatistics d = this.done[i];
                d.addValue(committed[1]);
                this.doneMean[i] = d.getMean();
                this.doneMax[i] = Math.round(d.getMax());
                // value per time
                value[i] = (float) (c.value() / (Math.max(1E3, /* 1uS in nanos */
                timeMeanNS) / 1E9));
            } else {
                // value[i] = unchanged
                // slowly forget
                value[i] *= 0.99f;
            }
        }
        // double[] tRange = Util.minmax(timeMean);
        // double tMin = tRange[0];
        // double tMax = tRange[1];
        // for (int i = 0; i < n; i++) {
        // double tNorm = normalize(timeMean[i], tMin, tMax);
        // value[i] /= ((float)tNorm);
        // }
        // weight[] = normalize(value[]) , with margin so the minimum value is non-zero some marginal amoutn (Margin-Max)
        float[] vRange = Util.minmax(value);
        float vMin = vRange[0];
        float vMax = vRange[1];
        // float lowMargin = (minmax[1] - minmax[0]) / n;
        for (int i = 0; i < n; i++) {
            double vNormPerTime = normalize(value[i], vMin, vMax);
            // ;
            int pri = (int) Util.clampI((PRI_GRANULARITY * vNormPerTime), 1, AtomicRoulette.PRI_GRANULARITY);
            // the priority determined by the value primarily affects the probability of the choice being selected as a timeslice
            priGetAndSet(i, pri);
            // the iters per timeslice is determined by past measurements
            long doneMost = doneMax[i];
            double timePerIter = timeMean[i];
            if (doneMost < 1 || !Double.isFinite(timePerIter)) {
                // assume only one iteration will consume entire timeslice
                timePerIter = timesliceNS;
            }
            sliceIters[i] = (int) Math.max(1, Math.ceil(// modulate growth by the normalized value
            (/*vNormPerTime * */
            timesliceNS / timePerIter) * Util.lerp(vNormPerTime, IterGrowthRateMin, IterGrowthRateMax) + IterGrowthIncrement));
        // System.out.println(this.choice.get(i) + " "+ vNormPerTime + " " + sliceIters[i]);
        }
    // System.out.println();
    } finally {
        updating.set(false);
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 14 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project lightning by automatictester.

the class RespTimeMedianTest method execute.

@Override
public void execute(ArrayList<String[]> originalJMeterTransactions) {
    try {
        JMeterTransactions transactions = filterTransactions((JMeterTransactions) originalJMeterTransactions);
        transactionCount = transactions.getTransactionCount();
        DescriptiveStatistics ds = new DescriptiveStatistics();
        for (String[] transaction : transactions) {
            String elapsed = transaction[1];
            ds.addValue(Double.parseDouble(elapsed));
        }
        longestTransactions = transactions.getLongestTransactions();
        actualResult = (int) ds.getPercentile(50);
        actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, actualResult);
        if (actualResult > maxRespTime) {
            result = TestResult.FAIL;
        } else {
            result = TestResult.PASS;
        }
    } catch (Exception e) {
        result = TestResult.ERROR;
        actualResultDescription = e.getMessage();
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions)

Example 15 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project lightning by automatictester.

the class RespTimeNthPercentileTest method execute.

@Override
public void execute(ArrayList<String[]> originalJMeterTransactions) {
    try {
        JMeterTransactions transactions = filterTransactions((JMeterTransactions) originalJMeterTransactions);
        transactionCount = transactions.getTransactionCount();
        DescriptiveStatistics ds = new DescriptiveStatistics();
        ds.setPercentileImpl(new Percentile().withEstimationType(Percentile.EstimationType.R_3));
        for (String[] transaction : transactions) {
            String elapsed = transaction[1];
            ds.addValue(Double.parseDouble(elapsed));
        }
        longestTransactions = transactions.getLongestTransactions();
        actualResult = (int) ds.getPercentile((double) percentile);
        actualResultDescription = String.format(ACTUAL_RESULT_MESSAGE, new IntToOrdConverter().convert(percentile), actualResult);
        if (actualResult > maxRespTime) {
            result = TestResult.FAIL;
        } else {
            result = TestResult.PASS;
        }
    } catch (Exception e) {
        result = TestResult.ERROR;
        actualResultDescription = e.getMessage();
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) Percentile(org.apache.commons.math3.stat.descriptive.rank.Percentile) IntToOrdConverter(uk.co.automatictester.lightning.utils.IntToOrdConverter) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions)

Aggregations

DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)75 ArrayList (java.util.ArrayList)12 TException (org.apache.thrift.TException)6 Plot (ij.gui.Plot)5 List (java.util.List)5 Test (org.junit.jupiter.api.Test)5 JMeterTransactions (uk.co.automatictester.lightning.data.JMeterTransactions)5 PinotDataBuffer (com.linkedin.pinot.core.segment.memory.PinotDataBuffer)4 Rectangle (java.awt.Rectangle)4 MersenneTwister (org.apache.commons.math3.random.MersenneTwister)4 SummaryStatistics (org.apache.commons.math3.stat.descriptive.SummaryStatistics)4 Percentile (org.apache.commons.math3.stat.descriptive.rank.Percentile)4 PeakResult (gdsc.smlm.results.PeakResult)3 ImagePlus (ij.ImagePlus)3 GenericDialog (ij.gui.GenericDialog)3 ImageProcessor (ij.process.ImageProcessor)3 File (java.io.File)3 WeightedObservedPoint (org.apache.commons.math3.fitting.WeightedObservedPoint)3 StoredDataStatistics (gdsc.core.utils.StoredDataStatistics)2 ImageStack (ij.ImageStack)2