@Override public String toString() { if (count() > 0) { return MoreObjects.toStringHelper(this) .add("count", count) .add("mean", mean) .add("populationStandardDeviation", populationStandardDeviation()) .add("min", min) .add("max", max) .toString(); } else { return MoreObjects.toStringHelper(this).add("count", count).toString(); } }
@Override public String toString() { if (count() > 0) { return MoreObjects.toStringHelper(this) .add("count", count) .add("mean", mean) .add("populationStandardDeviation", populationStandardDeviation()) .add("min", min) .add("max", max) .toString(); } else { return MoreObjects.toStringHelper(this).add("count", count).toString(); } }
@Override public String toString() { if (count() > 0) { return MoreObjects.toStringHelper(this) .add("count", count) .add("mean", mean) .add("populationStandardDeviation", populationStandardDeviation()) .add("min", min) .add("max", max) .toString(); } else { return MoreObjects.toStringHelper(this).add("count", count).toString(); } }
public void testPopulationStandardDeviation() { try { EMPTY_STATS_VARARGS.populationStandardDeviation(); fail("Expected IllegalStateException"); } catch (IllegalStateException expected) { EMPTY_STATS_ITERABLE.populationStandardDeviation(); fail("Expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(ONE_VALUE_STATS.populationStandardDeviation()).isWithin(0.0).of(0.0); assertThat(TWO_VALUES_STATS.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS / 2)); assertThat(MANY_VALUES_STATS_VARARGS.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(MANY_VALUES_STATS_ITERABLE.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(MANY_VALUES_STATS_ITERATOR.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(MANY_VALUES_STATS_SNAPSHOT.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(INTEGER_MANY_VALUES_STATS_VARARGS.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(INTEGER_MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / INTEGER_MANY_VALUES_COUNT)); assertThat(INTEGER_MANY_VALUES_STATS_ITERABLE.populationStandardDeviation())
public void testToString() { assertThat(EMPTY_STATS_VARARGS.toString()).isEqualTo("Stats{count=0}"); assertThat(MANY_VALUES_STATS_ITERABLE.toString()) .isEqualTo( "Stats{count=" + MANY_VALUES_STATS_ITERABLE.count() + ", mean=" + MANY_VALUES_STATS_ITERABLE.mean() + ", populationStandardDeviation=" + MANY_VALUES_STATS_ITERABLE.populationStandardDeviation() + ", min=" + MANY_VALUES_STATS_ITERABLE.min() + ", max=" + MANY_VALUES_STATS_ITERABLE.max() + "}"); }
.of( twoValuesAccumulator.populationCovariance() / (twoValuesAccumulator.xStats().populationStandardDeviation() * twoValuesAccumulator.yStats().populationStandardDeviation())); assertThat(manyValuesAccumulator.pearsonsCorrelationCoefficient()) .isWithin(ALLOWED_ERROR) .of( manyValuesAccumulator.populationCovariance() / (manyValuesAccumulator.xStats().populationStandardDeviation() * manyValuesAccumulator.yStats().populationStandardDeviation())); assertThat(manyValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient()) .isWithin(ALLOWED_ERROR) / (manyValuesAccumulatorByAddAllPartitionedPairedStats .xStats() .populationStandardDeviation() .populationStandardDeviation())); .of( accumulator.populationCovariance() / (accumulator.xStats().populationStandardDeviation() * accumulator.yStats().populationStandardDeviation())); assertThat(pearsonsCorrelationCoefficientByAddAllPartitionedPairedStats) .named("Pearson's correlation coefficient by addAll(PairedStats) of " + values) / (accumulatorByAddAllPartitionedPairedStats .xStats() .populationStandardDeviation()
.of( TWO_VALUES_PAIRED_STATS.populationCovariance() / (TWO_VALUES_PAIRED_STATS.xStats().populationStandardDeviation() * TWO_VALUES_PAIRED_STATS.yStats().populationStandardDeviation())); .of( stats.populationCovariance() / (stats.xStats().populationStandardDeviation() * stats.yStats().populationStandardDeviation()));
@Override public String toString() { if (count() > 0) { return MoreObjects.toStringHelper(this) .add("count", count) .add("mean", mean) .add("populationStandardDeviation", populationStandardDeviation()) .add("min", min) .add("max", max) .toString(); } else { return MoreObjects.toStringHelper(this).add("count", count).toString(); } }
@Override public String toString() { if (count() > 0) { return MoreObjects.toStringHelper(this) .add("count", count) .add("mean", mean) .add("populationStandardDeviation", populationStandardDeviation()) .add("min", min) .add("max", max) .toString(); } else { return MoreObjects.toStringHelper(this).add("count", count).toString(); } }
public void testPopulationStandardDeviation() { try { EMPTY_STATS_VARARGS.populationStandardDeviation(); fail("Expected IllegalStateException"); } catch (IllegalStateException expected) { EMPTY_STATS_ITERABLE.populationStandardDeviation(); fail("Expected IllegalStateException"); } catch (IllegalStateException expected) { assertThat(ONE_VALUE_STATS.populationStandardDeviation()).isWithin(0.0).of(0.0); assertThat(TWO_VALUES_STATS.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS / 2)); assertThat(MANY_VALUES_STATS_VARARGS.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(MANY_VALUES_STATS_ITERABLE.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(MANY_VALUES_STATS_ITERATOR.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(MANY_VALUES_STATS_SNAPSHOT.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / MANY_VALUES_COUNT)); assertThat(INTEGER_MANY_VALUES_STATS_VARARGS.populationStandardDeviation()) .isWithin(ALLOWED_ERROR) .of(sqrt(INTEGER_MANY_VALUES_SUM_OF_SQUARES_OF_DELTAS / INTEGER_MANY_VALUES_COUNT)); assertThat(INTEGER_MANY_VALUES_STATS_ITERABLE.populationStandardDeviation())
public void testToString() { assertThat(EMPTY_STATS_VARARGS.toString()).isEqualTo("Stats{count=0}"); assertThat(MANY_VALUES_STATS_ITERABLE.toString()) .isEqualTo( "Stats{count=" + MANY_VALUES_STATS_ITERABLE.count() + ", mean=" + MANY_VALUES_STATS_ITERABLE.mean() + ", populationStandardDeviation=" + MANY_VALUES_STATS_ITERABLE.populationStandardDeviation() + ", min=" + MANY_VALUES_STATS_ITERABLE.min() + ", max=" + MANY_VALUES_STATS_ITERABLE.max() + "}"); }
.of( twoValuesAccumulator.populationCovariance() / (twoValuesAccumulator.xStats().populationStandardDeviation() * twoValuesAccumulator.yStats().populationStandardDeviation())); assertThat(manyValuesAccumulator.pearsonsCorrelationCoefficient()) .isWithin(ALLOWED_ERROR) .of( manyValuesAccumulator.populationCovariance() / (manyValuesAccumulator.xStats().populationStandardDeviation() * manyValuesAccumulator.yStats().populationStandardDeviation())); assertThat(manyValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient()) .isWithin(ALLOWED_ERROR) / (manyValuesAccumulatorByAddAllPartitionedPairedStats .xStats() .populationStandardDeviation() .populationStandardDeviation())); .of( accumulator.populationCovariance() / (accumulator.xStats().populationStandardDeviation() * accumulator.yStats().populationStandardDeviation())); assertThat(pearsonsCorrelationCoefficientByAddAllPartitionedPairedStats) .named("Pearson's correlation coefficient by addAll(PairedStats) of " + values) / (accumulatorByAddAllPartitionedPairedStats .xStats() .populationStandardDeviation()
.of( TWO_VALUES_PAIRED_STATS.populationCovariance() / (TWO_VALUES_PAIRED_STATS.xStats().populationStandardDeviation() * TWO_VALUES_PAIRED_STATS.yStats().populationStandardDeviation())); .of( stats.populationCovariance() / (stats.xStats().populationStandardDeviation() * stats.yStats().populationStandardDeviation()));