public static double[] stdDeviation(final SampleSet set, final double[] mean) {
        if (set.size() == 0) return null;
        //
        final int inputsize   = set.get(0).getInputSize();
        final double[] result = new double[inputsize]; 
        long ctr = 0;
        //
        // compute the squared difference to the mean vector.
        //
        for (Sample sample : set) {
            //
            final double[] input = sample.getInput();
            int offset = 0;
            for (int s = 0; s < sample.getInputLength(); s++) {
                for (int i = 0; i < inputsize; i++) {
                    final double d = mean[i] - input[offset++];
                    result[i] += (d * d);
                }
                ctr++;
            }
        }
        //
        // finally compute the standard deviation.
        //
        final double inv = (1.0 / (double)(ctr - 1));
        //
        for (int i = 0; i < result.length; i++) {
            result[i] = Math.sqrt(result[i] * inv);
        }
        return result;        
    }