public static DoubleMatrix createAverages(int w, int h, double... values) {
        if (w == 0 || h == 0)
            throw new IllegalArgumentException(
                    "Dimensions must be bigger than 0!");

        double sum = 0;
        for (double value : values)
            sum += value;

        double avgs[] = new double[values.length];
        for (int i = 0; i < avgs.length; i++)
            avgs[i] = values[i] / sum;

        if (sum == 0)
            throw new IllegalArgumentException(
                    "The sum of the values cannot be zero!");

        return new DoubleMatrix(w, h, avgs);
    }