@Test
public void testPercentile() {

  // These tests come from examples in
  // https://en.wikipedia.org/wiki/Percentile#The_nearest-rank_method
  Distribution dist;
  dist = of(15, 20, 35, 40, 50);
  assertThat(dist.getPercentile(5)).isEqualTo(15);
  assertThat(dist.getPercentile(30)).isEqualTo(20);
  assertThat(dist.getPercentile(40)).isEqualTo(20);
  assertThat(dist.getPercentile(50)).isEqualTo(35);
  assertThat(dist.getPercentile(100)).isEqualTo(50);
  dist = of(3, 6, 7, 8, 8, 10, 13, 15, 16, 20);
  assertThat(dist.getPercentile(25)).isEqualTo(7);
  assertThat(dist.getPercentile(50)).isEqualTo(8);
  assertThat(dist.getPercentile(75)).isEqualTo(15);
  assertThat(dist.getPercentile(100)).isEqualTo(20);
  dist = of(3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20);
  assertThat(dist.getPercentile(25)).isEqualTo(7);
  assertThat(dist.getPercentile(50)).isEqualTo(9);
  assertThat(dist.getPercentile(75)).isEqualTo(15);
  assertThat(dist.getPercentile(100)).isEqualTo(20);
}