public static double ioa(double[] prediction, double[] validation, double pow) {
        double ioa;
        int td_size = prediction.length;
        int vd_size = validation.length;
        if (td_size != vd_size) {
            throw new IllegalArgumentException("Data sets in ioa does not match!");
        }

        int steps = td_size;

        double sum_td = 0;
        double sum_vd = 0;

        /**summing up both data sets */
        for (int i = 0; i < steps; i++) {
            sum_td = sum_td + prediction[i];
            sum_vd = sum_vd + validation[i];
        }

        /** calculating mean values for both data sets */
        double mean_td = sum_td / steps;
        double mean_vd = sum_vd / steps;

        /** calculating mean cubic deviations */
        double td_vd = 0;
        double vd_mean = 0;
        for (int i = 0; i < steps; i++) {
            td_vd = td_vd + (Math.pow((Math.abs(validation[i] - prediction[i])), pow));
            vd_mean = vd_mean + (Math.pow((Math.abs(validation[i] - mean_vd)), pow));
        }

        /** calculating absolute squared sum of deviations from verification mean */
        double ad_test = 0;
        double ad_veri = 0;
        double abs_sqDevi = 0;
        for (int i = 0; i < steps; i++) {
            abs_sqDevi = abs_sqDevi + Math.pow(Math.abs(prediction[i] - mean_vd) + Math.abs(validation[i] - mean_vd), pow);
        }

        /** calculating ioa */
        ioa = 1.0 - (td_vd / abs_sqDevi);
        return ioa;
    }
public static double ioa ( double [ ] prediction , double [ ] validation , double pow ) { double ioa ; int td_size = prediction . length ; int vd_size = validation . length ; if ( td_size != vd_size ) { throw new IllegalArgumentException ( "Data sets in ioa does not match!" ) ; } int steps = td_size ; double sum_td = 0 ; double sum_vd = 0 ; for ( int i = 0 ; i < steps ; i ++ ) { sum_td = sum_td + prediction [ i ] ; sum_vd = sum_vd + validation [ i ] ; } double mean_td = sum_td / steps ; double mean_vd = sum_vd / steps ; double td_vd = 0 ; double vd_mean = 0 ; for ( int i = 0 ; i < steps ; i ++ ) { td_vd = td_vd + ( Math . pow ( ( Math . abs ( validation [ i ] - prediction [ i ] ) ) , pow ) ) ; vd_mean = vd_mean + ( Math . pow ( ( Math . abs ( validation [ i ] - mean_vd ) ) , pow ) ) ; } double ad_test = 0 ; double ad_veri = 0 ; double abs_sqDevi = 0 ; for ( int i = 0 ; i < steps ; i ++ ) { abs_sqDevi = abs_sqDevi + Math . pow ( Math . abs ( prediction [ i ] - mean_vd ) + Math . abs ( validation [ i ] - mean_vd ) , pow ) ; } ioa = 1.0 - ( td_vd / abs_sqDevi ) ; return ioa ; }
Calculates the index of agreement (ioa) between a test data set and a verification data set
after Willmot & Wicks (1980). The ioa is described as the proportion of
the cumulated cubic deviation between both data sets and the squared sum of the absolute
deviations between the verification data set and the test mean value and the test data set and
its mean value.
@param prediction the test Data set
@param validation the verification data set
@param pow the power
@return the calculated ioa or -9999 if an error occurs