static double test(double[] w) {
        int success = 0;
        int trials = 0;

        for (int example = 5000; example < (int) I.size(); example++) {

            // valitetaan vain + ja - -luokista.
            if (I.elementAt(example).characterClass != targetChar
                    && I.elementAt(example).characterClass != oppositeChar) {
                continue;
            }

            // laske z
            double z = 0.0;
            for (int j = 0; j < 28 * 28; j++) {
                z += I.elementAt(example).vec[j] * w[j];
            }

            // oliko luokitus oikein?
            if ((z >= 0 && I.elementAt(example).characterClass == targetChar)
                    || (z < 0 && I.elementAt(example).characterClass == oppositeChar)) {
                success++;
            }
            trials++;
        }

        return (double) (trials - success) / trials;
    }