/**
 * Low discrepancy sequence
 * @param {number} i index of sequence element
 * @param {number} R a prime number
 * @param {number} count how many elements in the sequence
 * @returns {number}
 */
export function hammersley_sequence(i, R, count) {

    let t = i / count;

    for (let j = 0; j < i; j++) {
        const x = 1 - t;
        let y = 1 / R;

        while (x <= y) {
            y = y / R;
        }

        t += (R + 1) * y - 1;
    }

    return t;
}

