### Question:
IdentityByStateClustering { public int getFirstSampleIndex(int compoundIndex, int secondSampleIndex) { return compoundIndex - (secondSampleIndex * secondSampleIndex - secondSampleIndex) / 2; }  List<IdentityByState> countIBS(List<Variant> variants, List<String> samples); List<IdentityByState> countIBS(List<Variant> variants, List<String> samples,
                                          IBDExpectedFrequencies expectedFreqs); List<IdentityByState> countIBS(Variant variant, List<String> samples); List<IdentityByState> countIBS(Variant variant, List<String> samples, IBDExpectedFrequencies expectedFreqs); List<IdentityByState> countIBS(Iterator<Variant> iterator, List<String> samples); List<IdentityByState> countIBS(Iterator<Variant> iterator, List<String> samples,
                                          IBDExpectedFrequencies expectedFreqs); List<IdentityByState> initCounts(List<String> samples); void countIBS(Variant variant, List<String> samples, List<IdentityByState> counts); int countSharedAlleles(int allelesCount, Genotype genotypeFirst, Genotype genotypeSecond); int getAmountOfPairs(int samplesCount); int getCompoundIndex(int first, int second); int getSecondSampleIndex(int compoundIndex); int getFirstSampleIndex(int compoundIndex, int secondSampleIndex); void forEachPair(List<String> samples, SamplePairConsumer<E> loopBody); void write(OutputStream outputStream, List<IdentityByState> ibsList, List<String> samples); static final int MAX_SAMPLES_ALLOWED; }### Answer:
@Test public void testGetFirstSampleIndex() throws Exception { IdentityByStateClustering ibsc = new IdentityByStateClustering(); int n = 10000; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { assertEquals(i, ibsc.getFirstSampleIndex(ibsc.getCompoundIndex(i, j), j)); } } }