public static IntStream indexes(
		final RandomGenerator random,
		final int start,
		final int end,
		final double p
	) {
		requireNonNull(random);
		probability(p);

		if (isZero(p)) {
			return IntStream.empty();
		} else if (isOne(p)) {
			return IntStream.range(start, end);
		} else {
			final int P = Probabilities.toInt(p);
			return IntStream.range(start, end)
				.filter(i -> random.nextInt() < P);
		}
	}
Create an {@code IntStream} which creates random indexes within the
given range and the index probability.

@since 3.0

@param random the random engine used for calculating the random
       indexes
@param start the start index (inclusively)
@param end the end index (exclusively)
@param p the index selection probability
@return a new random index stream
@throws IllegalArgumentException if {@code p} is not a
        valid probability.
jenetics/src/main/java/io/jenetics/internal/math/Randoms.java