public double getHaltonNumber(int index, int base) {

        // Check base
        if(base < 2)
            base = 2;
        if(index < 0)
            index = 0;

        // Index shift: counting of the function starts at 0, algorithm below starts at 1.
        index++;

        // Calculate Halton number x
        double x = 0;

        double factor = 1.0/base;

        while(index > 0) {
            x += (index % base) * factor;
            factor /= base;
            index /= base;
        }
        return (min + x * ((max - min) + 1));
    }