WeightedPloidyHistogram { int bucket(double ploidy) { return (int) Math.round((ploidy - offset) / binWidth); } WeightedPloidyHistogram(final double maxPloidy, final double binWidth);   WeightedPloidyHistogram(final double maxPloidy, final double binWidth, final double offset); @NotNull double[] histogram(@NotNull final Collection<? extends WeightedPloidy> ploidies);  }
@Test public void testBucketWithOffset() { final WeightedPloidyHistogram negativeOffset = new WeightedPloidyHistogram(10, 0.05, -0.02); assertEquals(1, negativeOffset.bucket(0.05)); assertEquals(2, negativeOffset.bucket(0.06)); assertEquals(2, negativeOffset.bucket(0.08)); assertEquals(2, negativeOffset.bucket(0.10)); assertEquals(3, negativeOffset.bucket(0.11)); final WeightedPloidyHistogram positiveOffset = new WeightedPloidyHistogram(10, 0.05, 0.02); assertEquals(0, positiveOffset.bucket(0.04)); assertEquals(1, positiveOffset.bucket(0.05)); assertEquals(1, positiveOffset.bucket(0.07)); assertEquals(1, positiveOffset.bucket(0.09)); assertEquals(2, positiveOffset.bucket(0.10)); }