Here you can find the source of computeMeanSquareError(double[] x, double[] y)
Parameter | Description |
---|---|
x | the one array |
y | the other array |
public static double computeMeanSquareError(double[] x, double[] y)
//package com.java2s; /*/*from w w w. j a va 2s . c o m*/ * Copyright (C) 2010-2014 Andreas Maier * CONRAD is developed as an Open Source project under the GNU General Public License (GPL). */ public class Main { /** * computes the mean square error of array x to array y * * @param x the one array * @param y the other array * @return the mean square error */ public static double computeMeanSquareError(double[] x, double[] y) { double sum = 0; for (int i = 0; i < x.length; i++) { sum += Math.pow(x[i] - y[i], 2); } return sum / x.length; } /** * calls Math.pow for each element of the array * @param array * @param exp the exponent. * @return reference to the input array */ public static double[] pow(double[] array, double exp) { for (int i = 0; i < array.length; i++) { array[i] = Math.pow(array[i], exp); } return array; } }