import { clamp } from "../../../../../core/math/clamp.js";

const ONE_MINUS_EPSILON = 0.999999;

/**
 *
 * @param {number} index
 * @param {number} delta
 * @param {function} random
 * @return {number}
 */
export function make_stratified_sample(index, delta, random) {

    let sample = index + random();

    sample *= delta;

    sample = clamp(sample, 0, ONE_MINUS_EPSILON);

    return sample;
}