Example usage for org.apache.commons.math.stat.descriptive SummaryStatistics getMin

List of usage examples for org.apache.commons.math.stat.descriptive SummaryStatistics getMin

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive SummaryStatistics getMin.

Prototype

public double getMin() 

Source Link

Document

Returns the minimum of the values that have been added.

Usage

From source file:de.escidoc.core.om.performance.Statistics.java

/**
 * @return the statistics of all measured methods.
 *///from www  . j a va  2  s.c om
@ManagedAttribute(description = "Get all currently available statistics")
public String getKeys() {
    final StringBuilder b = new StringBuilder();
    for (final String key : this.statisticsMap.keySet()) {
        final SummaryStatistics s = getStatistics(key);
        if (s != null) {
            b.append(key).append(", #:").append(s.getN()).append(", min (ms):").append((long) s.getMin())
                    .append(", max (ms):").append((long) s.getMax()).append(", mean (ms):")
                    .append((long) s.getMean()).append(", stddev (ms):").append((long) s.getStandardDeviation())
                    .append(", total (ms):").append((long) s.getSum()).append('\n');
        }
    }
    System.gc();
    return b.toString();
}

From source file:gsn.tests.performance.Queries.java

private String printStats(SummaryStatistics stats, String unit) {
    return new StringBuilder().append("sum:").append(format(stats.getSum())).append(", min:")
            .append(format(stats.getMin())).append(", max:").append(format(stats.getMax())).append(", mean:")
            .append(format(stats.getMean())).append(", var:").append(format(stats.getVariance())).append(" [")
            .append(unit).append("]").toString();
}

From source file:geogebra.kernel.AlgoNormalQuantilePlot.java

private GeoSegment getQQLineSegment() {

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = 0; i < sortedData.length; i++) {
        stats.addValue(sortedData[i]);// w  w  w. jav  a2  s .  c  o  m
    }
    double sd = stats.getStandardDeviation();
    double mean = stats.getMean();
    double min = stats.getMin();
    double max = stats.getMax();

    // qq line: y = (1/sd)x - mean/sd 

    GeoPoint startPoint = new GeoPoint(cons);
    startPoint.setCoords(min, (min / sd) - mean / sd, 1.0);
    GeoPoint endPoint = new GeoPoint(cons);
    endPoint.setCoords(max, (max / sd) - mean / sd, 1.0);
    GeoSegment seg = new GeoSegment(cons, startPoint, endPoint);
    seg.calcLength();

    return seg;
}

From source file:geogebra.common.kernel.statistics.AlgoNormalQuantilePlot.java

private GeoSegment getQQLineSegment() {

    SummaryStatistics stats = new SummaryStatistics();
    for (int i = 0; i < sortedData.length; i++) {
        stats.addValue(sortedData[i]);//from  w ww .j a v  a 2  s .  c o  m
    }
    double sd = stats.getStandardDeviation();
    double mean = stats.getMean();
    double min = stats.getMin();
    double max = stats.getMax();

    // qq line: y = (1/sd)x - mean/sd

    GeoPoint startPoint = new GeoPoint(cons);
    startPoint.setCoords(min, (min / sd) - mean / sd, 1.0);
    GeoPoint endPoint = new GeoPoint(cons);
    endPoint.setCoords(max, (max / sd) - mean / sd, 1.0);
    GeoSegment seg = new GeoSegment(cons, startPoint, endPoint);
    seg.calcLength();

    return seg;
}

From source file:alma.acs.monitoring.blobber.BlobData.java

/**
 * Calculates the statistics and stores it in {@link #statistics}
 * if our monitor point data is represented as Number objects;
 * otherwise this call is ignored./*  w ww.  j a  va  2  s.  c  o  m*/
 * 
 * @param inDataList
 */
void calculateStatistics() {
    if (getDataSize() > 0) {

        // We trust that the data is homogeneous and check only the first MonitorPointValue

        MonitorPointValue sampleMonitorPointValue = mpTs.getDataList().get(0);

        if (sampleMonitorPointValue.getData().isEmpty()) {
            logger.finer(
                    "Ignoring calculateStatistics() call for a time series of MonitorPointValue objects that hold no data.");
            return;
        }

        // TODO: Should we also compute statistics for multi-valued properties?
        // This was not done in the original (= pre-ACS 12.0) implementation of BlobberWorker#calculateStatistics
        // and so far we keep this behavior. 
        if (sampleMonitorPointValue.isMultiValued()) {
            logger.finer(
                    "Ignoring calculateStatistics() call for a time series of multi-valued MonitorPointValue objects.");
            return;
        }

        // After the above checks, there should be a single data item in our sampleMonitorPointValue
        // We now verify that it has one of the expected numeric types.
        Object sampleData = sampleMonitorPointValue.getData().get(0);
        if (!(sampleData instanceof Integer || sampleData instanceof Long || sampleData instanceof Float
                || sampleData instanceof Double)) {
            logger.finer(
                    "Ignoring calculateStatistics() call for data type " + sampleData.getClass().getName());
            return;
        }

        // Now we calculate the statistics, 
        // using apache math lib that works only with 'double' type

        SummaryStatistics stat = new SummaryStatistics();
        for (MonitorPointValue blobData : mpTs.getDataList()) {
            Number value = (Number) blobData.getData().get(0);
            stat.addValue(value.doubleValue());
        }

        statistics = new ComponentStatistics();

        // We store the results in a ComponentStatistics object, 
        // converting to original data types where it makes sense
        if (sampleData instanceof Integer) {
            statistics.min = new Integer((int) Math.round(stat.getMin()));
            statistics.max = new Integer((int) Math.round(stat.getMax()));
            statistics.mean = new Double(stat.getMean()); // or Float, to indicate lower precision?
            statistics.stdDev = new Double(stat.getStandardDeviation()); // or Float, to indicate lower precision?
        } else if (sampleData instanceof Long) {
            statistics.min = new Long(Math.round(stat.getMin()));
            statistics.max = new Long(Math.round(stat.getMax()));
            statistics.mean = new Double(stat.getMean());
            statistics.stdDev = new Double(stat.getStandardDeviation());
        } else if (sampleData instanceof Float) {
            statistics.min = new Float(stat.getMin());
            statistics.max = new Float(stat.getMax());
            statistics.mean = new Float(stat.getMean());
            statistics.stdDev = new Float(stat.getStandardDeviation());
        } else if (sampleData instanceof Double) {
            statistics.min = new Double(stat.getMin());
            statistics.max = new Double(stat.getMax());
            statistics.mean = new Double(stat.getMean());
            statistics.stdDev = new Double(stat.getStandardDeviation());
        }
    }
}

From source file:edu.cornell.med.icb.goby.modes.CompactFileStatsMode.java

/**
 * Print statistics about an alignment file in the Goby compact form.
 *
 * @param file The file to display statistics about
 * @throws IOException if the file cannot be read
 *///from w  w w . j  ava2s. co  m

private void describeCompactAlignment(final File file) throws IOException {

    final String basename = AlignmentReaderImpl.getBasename(file.toString());
    stream.printf("Compact Alignment basename = %s%n", basename);

    final AlignmentReaderImpl reader = new AlignmentReaderImpl(basename);
    reader.readHeader();
    stream.println("Info from header:");
    stream.printf("Alignment written with Goby version=%s %n", reader.getGobyVersion());
    stream.printf("Alignment produced by aligner=%s version=%s %n", reader.getAlignerName(),
            reader.getAlignerVersion());
    stream.printf("Sorted: %b%n", reader.isSorted());
    stream.printf("Indexed: %b%n", reader.isIndexed());
    stream.printf("Number of target sequences = %,d%n", reader.getNumberOfTargets());
    final int[] targetLengthsFromHeader = reader.getTargetLength();
    stream.printf("Number of target length entries = %,d%n", ArrayUtils.getLength(reader.getTargetLength()));
    stream.printf("smallestSplitQueryIndex = %d%n", reader.getSmallestSplitQueryIndex());
    stream.printf("largestSplitQueryIndex = %d%n", reader.getLargestSplitQueryIndex());

    // simple statistics for target lengths
    final SummaryStatistics targetLengthStats = new SummaryStatistics();
    if (targetLengthsFromHeader != null) {
        for (final double d : targetLengthsFromHeader) {
            targetLengthStats.addValue(d);
        }
    }
    stream.printf("Min target length = %,d%n", (int) targetLengthStats.getMin());
    stream.printf("Max target length = %,d%n", (int) targetLengthStats.getMax());
    stream.printf("Mean target length = %,.2f%n", targetLengthStats.getMean());
    stream.println();

    stream.printf("Number of query sequences = %,d%n", reader.getNumberOfQueries());

    final SummaryStatistics queryLengthStats = new SummaryStatistics();

    stream.println("Query lengths stored in entries = " + reader.isQueryLengthStoredInEntries());
    stream.println("Constant query lengths = " + reader.isConstantQueryLengths());

    stream.printf("Has query identifiers = %s%n",
            reader.getQueryIdentifiers() != null && !reader.getQueryIdentifiers().isEmpty());
    final IndexedIdentifier targetIdentifiers = reader.getTargetIdentifiers();
    final boolean hasTargetIdentifiers = targetIdentifiers != null && !targetIdentifiers.isEmpty();
    stream.printf("Has target identifiers = %s%n", hasTargetIdentifiers);
    stream.printf("Has query index permutation = %s%n", reader.getQueryIndicesWerePermuted());
    stream.printf("Has query index occurrences = %s%n", reader.hasQueryIndexOccurrences());
    stream.printf("Has all read quality scores = %s%n", reader.getHasAllReadQualityScores());
    stream.printf("Has ambiguity = %s%n", reader.hasAmbiguity());

    if (verbose) {
        if (hasTargetIdentifiers) {
            for (Map.Entry<MutableString, Integer> entry : targetIdentifiers.entrySet()) {
                stream.printf("  Target %s=%d with a length of %d%n", entry.getKey(), entry.getValue(),
                        targetLengthsFromHeader[entry.getValue()]);
            }
        } else {
            for (Map.Entry<MutableString, Integer> entry : targetIdentifiers.entrySet()) {
                stream.printf("  Target %d with a length of %d%n", entry.getValue(),
                        targetLengthsFromHeader[entry.getValue()]);
            }
        }
    }

    stream.println();

    if (reader.getReadOriginInfo().size() > 0) {
        stream.println("---- Read Origin Info ------");
        for (final Alignments.ReadOriginInfo info : reader.getReadOriginInfo().getPbList()) {
            stream.println("[");
            stream.print(info.toString());
            stream.println("]");
        }
    } else {
        stream.println("Alignment has no Read Origin Info/Read Groups");
    }
    if (headerOnly)
        return;
    // the query indices that aligned. Includes those
    final DistinctIntValueCounterBitSet alignedQueryIndices = new DistinctIntValueCounterBitSet();

    describeAmbigousReads(basename, reader.getNumberOfQueries(), alignedQueryIndices);

    int maxQueryIndex = -1;
    int maxTargetIndex = -1;
    int numEntries = 0;
    long numLogicalAlignmentEntries = 0;
    long total = 0;
    double avgScore = 0;
    int sumNumVariations = 0;
    int numPaired = 0;
    int numProperlyPaired = 0;
    int numFirstInPair = 0;
    int numSecondInPair = 0;
    boolean hasSoftClips = false;

    for (final Alignments.AlignmentEntry entry : reader) {
        numberOfReads++; // Across all files
        numEntries++; // Across this file
        numLogicalAlignmentEntries += Math.max(entry.getMultiplicity(), 1);
        total += entry.getQueryAlignedLength();
        avgScore += entry.getScore();
        maxQueryIndex = Math.max(maxQueryIndex, entry.getQueryIndex());
        maxTargetIndex = Math.max(maxTargetIndex, entry.getTargetIndex());
        cumulativeReadLength += entry.getQueryAlignedLength();
        minReadLength = Math.min(minReadLength, entry.getQueryAlignedLength());
        maxReadLength = Math.max(maxReadLength, entry.getQueryAlignedLength());
        sumNumVariations += entry.getSequenceVariationsCount();
        alignedQueryIndices.observe(entry.getQueryIndex());
        hasSoftClips |= entry.hasSoftClippedBasesLeft();
        hasSoftClips |= entry.hasSoftClippedBasesRight();
        // check entry then header for the query length

        final double queryLength = entry.getQueryLength();
        queryLengthStats.addValue(queryLength);

        numPaired += EntryFlagHelper.isPaired(entry) ? 1 : 0;
        numProperlyPaired += EntryFlagHelper.isProperlyPaired(entry) ? 1 : 0;
        numFirstInPair += EntryFlagHelper.isFirstInPair(entry) ? 1 : 0;
        numSecondInPair += EntryFlagHelper.isSecondInPair(entry) ? 1 : 0;
    }

    avgScore /= (double) numLogicalAlignmentEntries;

    final int numQuerySequences = reader.getNumberOfQueries();
    stream.printf("num query indices = %,d%n", numQuerySequences);
    final int numTargetSequences = maxTargetIndex + 1;
    final double avgNumVariationsPerQuery = ((double) sumNumVariations) / (double) numQuerySequences;
    stream.printf("num target indices = %,d%n", numTargetSequences);
    stream.printf("Number of alignment entries = %,d%n", numLogicalAlignmentEntries);
    stream.printf("Number of query indices that matched = %,d%n", alignedQueryIndices.count());
    stream.printf("Percent matched = %4.1f %% %n",
            (double) alignedQueryIndices.count() / (double) ((long) numQuerySequences) * 100.0d);
    stream.printf("Avg query alignment length = %,f%n", numEntries > 0 ? divide(total, numEntries) : -1);
    stream.printf("Avg score alignment = %f%n", avgScore);
    stream.printf("Avg number of variations per query sequence = %3.2f %n", avgNumVariationsPerQuery);
    // size, the number of bytes in the entries file.
    final long size = new File(basename + ".entries").length();
    stream.printf("Average bytes per entry = %f%n", divide(size, numLogicalAlignmentEntries));

    stream.printf("Min query length = %,d%n", (int) queryLengthStats.getMin());
    stream.printf("Max query length = %,d%n", (int) queryLengthStats.getMax());
    final double meanQueryLength = queryLengthStats.getMean();
    stream.printf("Mean query length = %,.2f%n", meanQueryLength);
    final int averageReadLength = (int) (Math.round(meanQueryLength));
    stream.printf("Average bits per read base, assuming average read length %d = %f%n", averageReadLength,
            divide(size, numLogicalAlignmentEntries * averageReadLength));

    stream.printf("Percent paired reads = %,.2f %% %n", divide(numPaired, numQuerySequences * 2) * 100d);
    stream.printf("Percent properly paired reads = %,.2f %% %n",
            divide(numProperlyPaired, numQuerySequences * 2) * 100d);
    stream.printf("Percent first in pair = %,.2f %% %n", divide(numFirstInPair, numEntries) * 100d);
    stream.printf("Percent second in pair = %,.2f %% %n", divide(numSecondInPair, numEntries) * 100d);

    stream.printf("Aligment entries have some softClips: %b %n", hasSoftClips);
}

From source file:com.netflix.curator.framework.recipes.atomic.TestDistributedAtomicLong.java

@Test
public void testSimulation() throws Exception {
    final int threadQty = 20;
    final int executionQty = 50;

    final AtomicInteger optimisticTries = new AtomicInteger();
    final AtomicInteger promotedLockTries = new AtomicInteger();
    final AtomicInteger failures = new AtomicInteger();
    final AtomicInteger errors = new AtomicInteger();

    final SummaryStatistics timingStats = new SynchronizedSummaryStatistics();
    List<Future<Void>> procs = Lists.newArrayList();
    ExecutorService executorService = Executors.newFixedThreadPool(threadQty);
    for (int i = 0; i < threadQty; ++i) {
        Callable<Void> proc = new Callable<Void>() {
            @Override//from   w w  w  .ja  va  2  s  . com
            public Void call() throws Exception {
                doSimulation(executionQty, timingStats, optimisticTries, promotedLockTries, failures, errors);
                return null;
            }
        };
        procs.add(executorService.submit(proc));
    }

    for (Future<Void> f : procs) {
        f.get();
    }

    System.out.println("OptimisticTries: " + optimisticTries.get());
    System.out.println("PromotedLockTries: " + promotedLockTries.get());
    System.out.println("Failures: " + failures.get());
    System.out.println("Errors: " + errors.get());
    System.out.println();

    System.out.println("Avg time: " + timingStats.getMean());
    System.out.println("Max time: " + timingStats.getMax());
    System.out.println("Min time: " + timingStats.getMin());
    System.out.println("Qty: " + timingStats.getN());

    Assert.assertEquals(errors.get(), 0);
    Assert.assertTrue(optimisticTries.get() > 0);
    Assert.assertTrue(promotedLockTries.get() > 0);
}

From source file:it.univpm.deit.semedia.musicuri.utils.experimental.LambdaCalculator.java

public static void mergeStatistics(ArrayList allStats) {
    PerformanceStatistic tempStat;//  w w  w . j a v a2s . c  o m

    int truePositives = 0;
    int falsePositives = 0;
    int trueNegatives = 0;
    int falseNegatives = 0;

    SummaryStatistics TPBestMatchSummary = SummaryStatistics.newInstance();
    SummaryStatistics TPSecondBestSummary = SummaryStatistics.newInstance();

    SummaryStatistics FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics BothTP_FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics TNSummary = SummaryStatistics.newInstance();
    SummaryStatistics FNSummary = SummaryStatistics.newInstance();

    SummaryStatistics pruningSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics matchingSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics totalSpeedSummary = SummaryStatistics.newInstance();

    for (int i = 0; i < allStats.size(); i++) {
        tempStat = (PerformanceStatistic) allStats.get(i);

        if (tempStat.isTruePositive())
            truePositives++;
        if (tempStat.isFalsePositive())
            falsePositives++;
        if (tempStat.isTrueNegative())
            trueNegatives++;
        if (tempStat.isFalseNegative())
            falseNegatives++;

        // accurate results only
        //if (tempStat.isTruePositive() || tempStat.isTrueNegative())

        pruningSpeedSummary.addValue(tempStat.getPruningTime());
        matchingSpeedSummary.addValue(tempStat.getMatchingTime());
        totalSpeedSummary.addValue(tempStat.getPruningTime() + tempStat.getMatchingTime());

        if (tempStat.isTruePositive()) {
            TPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
            TPSecondBestSummary.addValue(tempStat.getSecondBestMatchDistance());
        }

        if (tempStat.isFalsePositive()) {
            FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
        }

        BothTP_FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());

    }

    System.out.println("---------------------------------------------------------");

    System.out.println("\nTrue Positives      : " + truePositives + "/" + allStats.size());
    System.out.println("False Positives     : " + falsePositives + "/" + allStats.size());
    System.out.println("True Negatives      : " + trueNegatives + "/" + allStats.size());
    System.out.println("False Negatives     : " + falseNegatives + "/" + allStats.size());

    System.out.println("\nTrue Positive Best Match Statistics");
    System.out.println("Distance Min        : " + TPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + TPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + TPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + TPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + TPBestMatchSummary.getStandardDeviation());
    System.out.println("Confidence Mean     : " + (100 - (100 * (TPBestMatchSummary.getMean()))) + " %");

    System.out.println("\nTrue Positive Second Best Statistics");
    System.out.println("Distance Min        : " + TPSecondBestSummary.getMin());
    System.out.println("Distance Max        : " + TPSecondBestSummary.getMax());
    System.out.println("Distance Mean       : " + TPSecondBestSummary.getMean());
    System.out.println("Confidence Mean     : " + (100 - (100 * (TPSecondBestSummary.getMean()))) + " %");

    System.out.println("\nFalse Positive Best Match Statistics");
    System.out.println("Distance Min        : " + FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + FPBestMatchSummary.getStandardDeviation());
    System.out.println("Confidence Mean     : " + (100 - (100 * (FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\nBest Match Statistics (Regardless being False or True Positive) ");
    System.out.println("Distance Min        : " + BothTP_FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + BothTP_FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + BothTP_FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + BothTP_FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + BothTP_FPBestMatchSummary.getStandardDeviation());
    System.out.println("Confidence Mean     : " + (100 - (100 * (BothTP_FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\n\nPruning Speed Statistics");
    System.out.println("Speed Min           : " + (pruningSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (pruningSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (pruningSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nMatching Speed Statistics");
    System.out.println("Speed Min           : " + (matchingSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (matchingSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (matchingSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nOverall Speed Statistics");
    System.out.println("Speed Min           : " + (totalSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (totalSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (totalSpeedSummary.getMean() / 1000) + " sec");

}

From source file:it.univpm.deit.semedia.musicuri.core.MusicURISearch.java

/**
 * Accumulates and prints performance statistics regarding speed and accuracy for a certain batch of tests. 
 * @param allStats an ArrayList containing PerformanceStatistic objects
 *///  ww  w. ja  v  a2  s  . c o  m
public void mergeStatistics(ArrayList allStats) {
    PerformanceStatistic tempStat;

    int truePositives = 0;
    int falsePositives = 0;
    int trueNegatives = 0;
    int falseNegatives = 0;

    SummaryStatistics TPBestMatchSummary = SummaryStatistics.newInstance();
    SummaryStatistics SecondBestSummary = SummaryStatistics.newInstance();
    SummaryStatistics WorstMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics BothTP_FPBestMatchSummary = SummaryStatistics.newInstance();

    SummaryStatistics TNSummary = SummaryStatistics.newInstance();
    SummaryStatistics FNSummary = SummaryStatistics.newInstance();

    SummaryStatistics pruningSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics matchingSpeedSummary = SummaryStatistics.newInstance();
    SummaryStatistics totalSpeedSummary = SummaryStatistics.newInstance();

    for (int i = 0; i < allStats.size(); i++) {
        tempStat = (PerformanceStatistic) allStats.get(i);

        if (tempStat.isTruePositive())
            truePositives++;
        if (tempStat.isFalsePositive())
            falsePositives++;
        if (tempStat.isTrueNegative())
            trueNegatives++;
        if (tempStat.isFalseNegative())
            falseNegatives++;

        // accurate results only
        //if (tempStat.isTruePositive() || tempStat.isTrueNegative())

        pruningSpeedSummary.addValue(tempStat.getPruningTime());
        matchingSpeedSummary.addValue(tempStat.getMatchingTime());
        totalSpeedSummary.addValue(tempStat.getPruningTime() + tempStat.getMatchingTime());

        if (tempStat.isTruePositive()) {
            TPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
            SecondBestSummary.addValue(tempStat.getSecondBestMatchDistance());
        }

        if (tempStat.isFalsePositive()) {
            FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
        }

        BothTP_FPBestMatchSummary.addValue(tempStat.getBestMatchDistance());
        WorstMatchSummary.addValue(tempStat.getWorstMatchDistance());
    }

    System.out.println("---------------------------------------------------------");

    System.out.println("\nTrue Positives      : " + truePositives + "/" + allStats.size());
    System.out.println("False Positives     : " + falsePositives + "/" + allStats.size());
    System.out.println("True Negatives      : " + trueNegatives + "/" + allStats.size());
    System.out.println("False Negatives     : " + falseNegatives + "/" + allStats.size());

    System.out.println("\nTrue Positive Best Match Statistics");
    System.out.println("Distance Min        : " + TPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + TPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + TPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + TPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + TPBestMatchSummary.getStandardDeviation());
    System.out.println("Score Mean          : " + (100 - (100 * (TPBestMatchSummary.getMean()))) + " %");

    System.out.println("\n2nd Match Statistics");
    System.out.println("Distance Min        : " + SecondBestSummary.getMin());
    System.out.println("Distance Max        : " + SecondBestSummary.getMax());
    System.out.println("Distance Mean       : " + SecondBestSummary.getMean());
    System.out.println("Score Mean          : " + (100 - (100 * (SecondBestSummary.getMean()))) + " %");

    System.out.println("\nNth Match Statistics");
    System.out.println("Distance Min        : " + WorstMatchSummary.getMin());
    System.out.println("Distance Max        : " + WorstMatchSummary.getMax());
    System.out.println("Distance Mean       : " + WorstMatchSummary.getMean());
    System.out.println("Score Mean          : " + (100 - (100 * (WorstMatchSummary.getMean()))) + " %");

    System.out.println("\nFalse Positive Best Match Statistics");
    System.out.println("Distance Min        : " + FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + FPBestMatchSummary.getStandardDeviation());
    System.out.println("Score Mean          : " + (100 - (100 * (FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\nBest Match Statistics (Regardless being False or True Positive) ");
    System.out.println("Distance Min        : " + BothTP_FPBestMatchSummary.getMin());
    System.out.println("Distance Max        : " + BothTP_FPBestMatchSummary.getMax());
    System.out.println("Distance Mean       : " + BothTP_FPBestMatchSummary.getMean());
    System.out.println("Distance Variance   : " + BothTP_FPBestMatchSummary.getVariance());
    System.out.println("Distance StdDev     : " + BothTP_FPBestMatchSummary.getStandardDeviation());
    System.out.println("Score Mean          : " + (100 - (100 * (BothTP_FPBestMatchSummary.getMean()))) + " %");

    System.out.println("\n\nPruning Speed Statistics");
    System.out.println("Speed Min           : " + (pruningSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (pruningSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (pruningSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nMatching Speed Statistics");
    System.out.println("Speed Min           : " + (matchingSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (matchingSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (matchingSpeedSummary.getMean() / 1000) + " sec");

    System.out.println("\nOverall Speed Statistics");
    System.out.println("Speed Min           : " + (totalSpeedSummary.getMin() / 1000) + " sec");
    System.out.println("Speed Max           : " + (totalSpeedSummary.getMax() / 1000) + " sec");
    System.out.println("Speed Mean          : " + (totalSpeedSummary.getMean() / 1000) + " sec");

}

From source file:org.apache.hadoop.hive.ql.exec.tez.TestHostAffinitySplitLocationProvider.java

private double testHashDistribution(int locs, final int missCount, FileSplit[] splits,
        AtomicInteger errorCount) {
    // This relies heavily on what method determineSplits ... calls and doesn't.
    // We could do a wrapper with only size() and get() methods instead of List, to be sure.
    @SuppressWarnings("unchecked")
    List<String> partLocs = (List<String>) Mockito.mock(List.class);
    Mockito.when(partLocs.size()).thenReturn(locs);
    final AtomicInteger state = new AtomicInteger(0);
    Mockito.when(partLocs.get(Mockito.anyInt())).thenAnswer(new Answer<String>() {
        @Override/*from w  w w  . ja v a 2  s  . c  om*/
        public String answer(InvocationOnMock invocation) throws Throwable {
            return (state.getAndIncrement() == missCount) ? "not-null" : null;
        }
    });
    int[] hitCounts = new int[locs];
    for (int splitIx = 0; splitIx < splits.length; ++splitIx) {
        state.set(0);
        int index = HostAffinitySplitLocationProvider.determineLocation(partLocs,
                splits[splitIx].getPath().toString(), splits[splitIx].getStart(), null);
        ++hitCounts[index];
    }
    SummaryStatistics ss = new SummaryStatistics();
    for (int hitCount : hitCounts) {
        ss.addValue(hitCount);
    }
    // All of this is completely bogus and mostly captures the following function:
    // f(output) = I-eyeballed-the(output) == they-look-ok.
    // It's pretty much a golden file... 
    // The fact that stdev doesn't increase with increasing missCount is captured outside.
    double avg = ss.getSum() / ss.getN(), stdev = ss.getStandardDeviation(), cv = stdev / avg;
    double allowedMin = avg - 2.5 * stdev, allowedMax = avg + 2.5 * stdev;
    if (allowedMin > ss.getMin() || allowedMax < ss.getMax() || cv > 0.22) {
        LOG.info("The distribution for " + locs + " locations, " + missCount + " misses isn't to "
                + "our liking: avg " + avg + ", stdev " + stdev + ", cv " + cv + ", min " + ss.getMin()
                + ", max " + ss.getMax());
        errorCount.incrementAndGet();
    }
    return cv;
}