### Question:
NegativeSampleProducer { public long nextSample() { long index = contextNodeDistribution.binarySearch(ThreadLocalRandom.current().nextLong(cumulativeProbability)); if (index < contextNodeDistribution.size() - 1) { index++; } return index; } NegativeSampleProducer(
        HugeLongArray contextNodeDistribution
    ); long nextSample();  }### Answer:
@Test void shouldProduceSamplesAccordingToNodeDistribution() { var walks = HugeObjectArray.of( new long[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, new long[]{1} ); var probabilityComputer = new ProbabilityComputer(walks, 2, 0.001, 0.75, 4, AllocationTracker.empty()); var sampler = new NegativeSampleProducer(probabilityComputer.getContextNodeDistribution()); Map<Long, Integer> distribution = IntStream .range(0, 1300) .mapToObj(ignore -> sampler.nextSample()) .collect(Collectors.toMap( Function.identity(), ignore -> 1, Integer::sum )); assertEquals(1.0 / 12, distribution.get(1L).doubleValue() / distribution.get(0L), 0.1); }