package com.gyee.generation.util.math;

public class PowerPredictionErrorCalculator {


    public static double calculateMaxErrorPercentage(double[] predictedPower, double[] actualPower, double installedCapacity) {
        int n = predictedPower.length;
        double maxErrorPercentage = 0.0;

        for (int i = 0; i < n; i++) {
            double errorPercentage = 0.0;

            if (predictedPower[i] == 0) {
                if (Math.abs(actualPower[i]) <= 0.03 * installedCapacity) {
                    continue; // 不考核
                } else {
                    errorPercentage = 100.0;
                }
            } else {
                errorPercentage = Math.abs(predictedPower[i] - actualPower[i]) / predictedPower[i] * 100;
            }

            if (errorPercentage > maxErrorPercentage) {
                maxErrorPercentage = errorPercentage;
            }
        }

        return maxErrorPercentage;
    }
}