/** * {@inheritDoc}. This version returns the mean of all the aggregated data. * * @see StatisticalSummary#getMean() */ public double getMean() { synchronized (statistics) { return statistics.getMean(); } }
/** * {@inheritDoc} */ @Override public synchronized double getMean() { return super.getMean(); }
/** * {@inheritDoc} * @since 3.1 */ public double getNumericalMean() { return sampleStats.getMean(); }
/** * Generates a text report displaying summary statistics from values that * have been added. * @return String with line feeds displaying statistics * @since 1.2 */ @Override public String toString() { StringBuilder outBuffer = new StringBuilder(); String endl = "\n"; outBuffer.append("SummaryStatistics:").append(endl); outBuffer.append("n: ").append(getN()).append(endl); outBuffer.append("min: ").append(getMin()).append(endl); outBuffer.append("max: ").append(getMax()).append(endl); outBuffer.append("sum: ").append(getSum()).append(endl); outBuffer.append("mean: ").append(getMean()).append(endl); outBuffer.append("geometric mean: ").append(getGeometricMean()) .append(endl); outBuffer.append("variance: ").append(getVariance()).append(endl); outBuffer.append("population variance: ").append(getPopulationVariance()).append(endl); outBuffer.append("second moment: ").append(getSecondMoment()).append(endl); outBuffer.append("sum of squares: ").append(getSumsq()).append(endl); outBuffer.append("standard deviation: ").append(getStandardDeviation()) .append(endl); outBuffer.append("sum of logs: ").append(getSumOfLogs()).append(endl); return outBuffer.toString(); }
/** * The within-bin smoothing kernel. Returns a Gaussian distribution * parameterized by {@code bStats}, unless the bin contains only one * observation, in which case a constant distribution is returned. * * @param bStats summary statistics for the bin * @return within-bin kernel parameterized by bStats */ protected RealDistribution getKernel(SummaryStatistics bStats) { if (bStats.getN() == 1 || bStats.getVariance() == 0) { return new ConstantRealDistribution(bStats.getMean()); } else { return new NormalDistribution(randomData.getRandomGenerator(), bStats.getMean(), bStats.getStandardDeviation(), NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); } } }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * statistics. * @return Current values of statistics */ public StatisticalSummary getSummary() { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); }
@Override public double[] compute(final Map<String, Object> combinedAggregators) { final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators); final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()]; Arrays.setAll(stats, i -> new SummaryStatistics()); final ArrayOfDoublesSketchIterator it = sketch.iterator(); while (it.next()) { final double[] values = it.getValues(); for (int i = 0; i < values.length; i++) { stats[i].addValue(values[i]); } } final double[] means = new double[sketch.getNumValues()]; Arrays.setAll(means, i -> stats[i].getMean()); return means; }
/** * Returns true iff <code>object</code> is a * <code>SummaryStatistics</code> instance and all statistics have the * same values as this. * @param object the object to test equality against. * @return true if object equals this */ @Override public boolean equals(Object object) { if (object == this) { return true; } if (object instanceof SummaryStatistics == false) { return false; } SummaryStatistics stat = (SummaryStatistics)object; return Precision.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) && Precision.equalsIncludingNaN(stat.getMax(), getMax()) && Precision.equalsIncludingNaN(stat.getMean(), getMean()) && Precision.equalsIncludingNaN(stat.getMin(), getMin()) && Precision.equalsIncludingNaN(stat.getN(), getN()) && Precision.equalsIncludingNaN(stat.getSum(), getSum()) && Precision.equalsIncludingNaN(stat.getSumsq(), getSumsq()) && Precision.equalsIncludingNaN(stat.getVariance(), getVariance()); }
private static Stats getStats(NumericColumn<?> values, SummaryStatistics summaryStatistics) { Stats stats = new Stats("Column: " + values.name()); stats.min = summaryStatistics.getMin(); stats.max = summaryStatistics.getMax(); stats.n = summaryStatistics.getN(); stats.sum = summaryStatistics.getSum(); stats.variance = summaryStatistics.getVariance(); stats.populationVariance = summaryStatistics.getPopulationVariance(); stats.quadraticMean = summaryStatistics.getQuadraticMean(); stats.geometricMean = summaryStatistics.getGeometricMean(); stats.mean = summaryStatistics.getMean(); stats.standardDeviation = summaryStatistics.getStandardDeviation(); stats.sumOfLogs = summaryStatistics.getSumOfLogs(); stats.sumOfSquares = summaryStatistics.getSumsq(); stats.secondMoment = summaryStatistics.getSecondMoment(); return stats; }
/** * Returns hash code based on values of statistics * @return hash code */ @Override public int hashCode() { int result = 31 + MathUtils.hash(getGeometricMean()); result = result * 31 + MathUtils.hash(getGeometricMean()); result = result * 31 + MathUtils.hash(getMax()); result = result * 31 + MathUtils.hash(getMean()); result = result * 31 + MathUtils.hash(getMin()); result = result * 31 + MathUtils.hash(getN()); result = result * 31 + MathUtils.hash(getSum()); result = result * 31 + MathUtils.hash(getSumsq()); result = result * 31 + MathUtils.hash(getVariance()); return result; }
public double sharpeRatio() { if (stats.getN() == 0) { return 0.00001; } double stdDev = stats.getStandardDeviation(); return stats.getMean() / (stdDev == 0.0 ? 100.0 : stdDev); }
public void print(String indent) { logHistogram.print(indent); System.out.println(); System.out.printf("%smin:%,11.2f max:%,11.2f avg:%,11.2f stddev:%,11.2f\n", indent, stats.getMin(), stats.getMax(), stats.getMean(), stats.getStandardDeviation()); } }
Double.toString(summStats.getMean()));
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TokenStatistics that = (TokenStatistics) o; if (totalTokens != that.totalTokens) return false; if (totalUniqueTokens != that.totalUniqueTokens) return false; if (!doubleEquals(that.entropy, entropy)) return false; // Probably incorrect - comparing Object[] arrays with Arrays.equals if (!Arrays.equals(topN, that.topN)) return false; SummaryStatistics thatS = ((TokenStatistics) o).summaryStatistics; if (summaryStatistics.getN() != thatS.getN()) return false; //if both have n==0, don't bother with the stats if (summaryStatistics.getN() ==0L) return true; //TODO: consider adding others... if (!doubleEquals(summaryStatistics.getGeometricMean(), thatS.getGeometricMean())) return false; if (!doubleEquals(summaryStatistics.getMax(), thatS.getMax())) return false; if (!doubleEquals(summaryStatistics.getMean(), thatS.getMean())) return false; if (!doubleEquals(summaryStatistics.getMin(), thatS.getMin())) return false; if (!doubleEquals(summaryStatistics.getSum(), thatS.getSum())) return false; if (!doubleEquals(summaryStatistics.getStandardDeviation(), thatS.getStandardDeviation())) return false; return true; }
/** * {@inheritDoc} * @since 3.1 */ public double getNumericalMean() { return sampleStats.getMean(); }
/** * {@inheritDoc} * @since 3.1 */ public double getNumericalMean() { return sampleStats.getMean(); }
/** * {@inheritDoc} */ @Override public synchronized double getMean() { return super.getMean(); }
/** * {@inheritDoc}. This version returns the mean of all the aggregated data. * * @see StatisticalSummary#getMean() */ public double getMean() { synchronized (statistics) { return statistics.getMean(); } }
public void print(String indent) { logHistogram.print(indent); System.out.println(); System.out.printf("%smin:%,11.2f max:%,11.2f avg:%,11.2f stddev:%,11.2f\n", indent, stats.getMin(), stats.getMax(), stats.getMean(), stats.getStandardDeviation()); } }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * statistics. * @return Current values of statistics */ public StatisticalSummary getSummary() { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); }