assertEquals(0, d1.getCount(10324324));
}
@Test
public void testMerge() {
DiscreteDistribution d1 = new DiscreteDistribution(new int[] {1,1,1,8,8,8,9,22,22,22,22,22});
DiscreteDistribution d2 = new DiscreteDistribution(new int[] {1,1,1,8,8,8,9,22,22,22,22,22});
DiscreteDistribution merged = DiscreteDistribution.merge(d1, d2);
assertEquals(3 * 2, merged.getCount(1));
assertEquals(3 * 2, merged.getCount(8));
assertEquals(2, merged.getCount(9));
assertEquals(5 * 2, merged.getCount(22));
assertEquals(0, merged.getCount(0));
assertEquals(0, merged.getCount(10));
assertEquals(0, merged.getCount(10324324));
DiscreteDistribution d3 = new DiscreteDistribution(new int[] {1,7,8,1000,1000,1000,2000,2000,30000});
DiscreteDistribution merged2 = DiscreteDistribution.merge(d1, d3);
assertEquals(4, merged2.getCount(1));
assertEquals(1, merged2.getCount(7));
assertEquals(4, merged2.getCount(8));
assertEquals(1, merged2.getCount(9));
assertEquals(5, merged2.getCount(22));
assertEquals(3, merged2.getCount(1000));
assertEquals(2, merged2.getCount(2000));
assertEquals(1, merged2.getCount(30000));
assertEquals(8, merged2.size());
DiscreteDistribution empty = new DiscreteDistribution();
DiscreteDistribution mergedWithEmpty = DiscreteDistribution.merge(empty, d1);
DiscreteDistribution mergedWithEmpty2 = DiscreteDistribution.merge(d2, empty);
assertTrue(d1 == mergedWithEmpty);
assertTrue(d2 == mergedWithEmpty2);
}