public float nextVonNeumann() {
        int   n;
        int   k = 0;
        float u1;
        
        // Loop to try sequences of uniformly-distributed
        // random values.
        for (;;) {
            n  = 1;
            u1 = gen.nextFloat();
            
            float u     = u1;
            float uPrev = Float.NaN;
            
            // Loop to generate a sequence of ramdom values
            // as long as they are decreasing.
            for (;;) {
                uPrev = u;
                u     = gen.nextFloat();
                // No longer decreasing?
                if (u > uPrev) {
                    // n is even.
                    if ((n & 1) == 0) {
                        return u1 + k;  // return a random value
                    }
                    // n is odd.
                    else {
                        ++k;
                        break;          // try another sequence
                    }
                }
                ++n;
            }
        }
    }