### Question:
Histogram { public Histogram<T> setBucketCount( int count ) { if (count != this.bucketCount) { this.bucketCount = count; this.bucketWidth = null; this.buckets.clear(); } return this; } Histogram( MathOperations<T> operations,
                      List<T> values );  Histogram( MathOperations<T> operations,
                      T... values ); BucketingStrategy getStrategy(); MathOperations<T> getMathOperations(); void setStrategy( double median,
                             double standardDeviation,
                             int sigma ); void setStrategy( T minimum,
                             T maximum ); void setStrategyToDefault(); int getSignificantFigures(); Histogram<T> setSignificantFigures( int significantFigures ); int getBucketCount(); Histogram<T> setBucketCount( int count ); List<Bucket> getBuckets(); long getTotalNumberOfValues(); List<String> getTextGraph( int maxBarLength ); static final int DEFAULT_BUCKET_COUNT; static final int DEFAULT_SIGNIFICANT_FIGURES; }### Answer:
@Test public void shouldCorrectlyPlaceAnEvenNumberOfFloatValuesIntoSmallerNumberOfBuckets() { Float[] values = {3.0f, 1.0f, 2.0f, 4.0f}; Histogram<Float> gram = new Histogram<Float>(new FloatOperations(), values); gram.setBucketCount(2); assertBucketValueCount(gram, 2, 2); }
@Test public void shouldCorrectlyPlaceAnOddNumberOfFloatValuesIntoSmallerNumberOfBucketsWithMinimumAndMaximumRanges() { Float[] values = {3.0f, 1.0f, 2.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}; Histogram<Float> gram = new Histogram<Float>(new FloatOperations(), values); gram.setBucketCount(5); assertBucketValueCount(gram, 2, 2, 2, 2, 2); }
@Test public void shouldCorrectlyPlaceAnOddNumberOfFloatValuesIntoSmallerNumberOfBucketsWithMinimumRanges() { Float[] values = {3.0f, 1.0f, 2.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 9.999f}; Histogram<Float> gram = new Histogram<Float>(new FloatOperations(), values); gram.setBucketCount(5); assertBucketValueCount(gram, 2, 2, 2, 2, 2); }
@Test public void shouldCorrectlyPlaceAnOddNumberOfFloatValuesIntoSameOddNumberOfBuckets() { Float[] values = {3.0f, 1.0f, 2.0f, 4.0f}; Histogram<Float> gram = new Histogram<Float>(new FloatOperations(), values); gram.setBucketCount(3); assertBucketValueCount(gram, 1, 1, 2); }
@Test public void shouldCorrectlyPlaceAnEvenNumberOfFloatValuesIntoSameEvenNumberOfBuckets() { Float[] values = {3.0f, 1.0f, 2.0f, 4.0f}; Histogram<Float> gram = new Histogram<Float>(new FloatOperations(), values); gram.setBucketCount(4); assertBucketValueCount(gram, 1, 1, 1, 1); }
@Test public void shouldCorrectlyPlaceAnOddNumberOfFloatValuesIntoSmallerNumberOfBuckets() { Float[] values = {3.0f, 1.0f, 2.0f}; Histogram<Float> gram = new Histogram<Float>(new FloatOperations(), values); gram.setBucketCount(2); assertBucketValueCount(gram, 1, 2); }