static double mse(final Double[] calculated, final Double[] expected) {
		if (expected.length != calculated.length) {
			throw new IllegalArgumentException(format(
				"Expected result and calculated results have different " +
					"length: %d != %d",
				expected.length, calculated.length
			));
		}

		double result = 0;
		for (int i = 0; i < expected.length; ++i) {
			result += (expected[i] - calculated[i])*(expected[i] - calculated[i]);
		}
		if (expected.length > 0) {
			result = result/expected.length;
		}

		return result;
	}
Mean square error is measured as the average of squared difference
between predictions and actual observations.

@see #rmse(Double[], Double[])

@param calculated the function values calculated with the current program
       tree
@param expected the expected function value as given by the sample points
@return the mean square error
@throws IllegalArgumentException if the length of the two arrays is not
        equal
@throws NullPointerException if one of the {@code double[]} arrays is
        {@code null}
jenetics.prog/src/main/java/io/jenetics/prog/regression/LossFunction.java