public static SampleSet generateData(final int bits, final Random rnd) {
        //
        final SampleSet result = new SampleSet();
        //
        final double[] input  = new double[bits];
        final double[] output = new double[2];
        //
        final int samples = 1 << bits;
        //
        for (int i = 0; i < samples; i++) {
            //
            // add 1 bit to bit-string.
            //
            for (int j = 0; j < bits; j++) {
                if (input[j] == OFF) {
                    //
                    // 0**** -> 1**** 
                    //
                    input[j] = ON;
                    break;
                } else {
                    //
                    // *1**** -> *0****
                    //
                    input[j] = OFF;
                }
            }
            //
            // generate parity sample
            //
            boolean parity = true;
            //
            for (int j = 0; j < bits; j++) {
                if (input[j] == ON) {
                    parity = !parity;
                }  
            }
            //
            if (parity) {
                output[CLASS_EVEN] = ON;
                output[CLASS_ODD]  = OFF; 
            } else {
                output[CLASS_EVEN] = OFF;
                output[CLASS_ODD]  = ON; 
            }
            //
            result.add(new Sample(input.clone(), output.clone()));
        }
        //
        Collections.shuffle(result, rnd);
        //
        return result;
    }