src/main/java/it/uniroma2/dicii/sabd/covidproject/utils/GlobalDataUtils.java
/*
     *  Estimate the trend line coefficient used to identify the mostly affected regions.
     *  The estimate is computed considering the slope of the regression line against the confirmed daily increments
     *  of a region.
     * */
Estimate the trend line coefficient used to identify the mostly affected regions.
The estimate is computed considering the slope of the regression line against the confirmed daily increments
of a region.
Estimate the trend line coefficient used to identify the mostly affected regions . The estimate is computed considering the slope of the regression line against the confirmed daily increments of a region .
public static Double computeCoefficientEstimate(Double[] confirmedDailyIncrements) {
        Double avgIncrements;
        Double incrementsSum = 0D;
        int n = confirmedDailyIncrements.length;
        for (Double confirmedDailyIncrement : confirmedDailyIncrements) {
            incrementsSum += confirmedDailyIncrement;
        }
        avgIncrements = incrementsSum / n;
        double num = 0F;
        double den = 0F;
        for (int i = 1; i <= n; i++) {
            num += (i-(double)(n+1)/2)*(confirmedDailyIncrements[i-1]-avgIncrements);
            den += (i-(double)(n+1)/2)*(i-(double)(n+1)/2);
        }
        return num / den;
    }
public static Double computeCoefficientEstimate ( Double [ ] confirmedDailyIncrements ) { Double avgIncrements ; Double incrementsSum = 0D ; int n = confirmedDailyIncrements . length ; for ( Double confirmedDailyIncrement : confirmedDailyIncrements ) { incrementsSum += confirmedDailyIncrement ; } avgIncrements = incrementsSum / n ; double num = 0F ; double den = 0F ; for ( int i = 1 ; i <= n ; i ++ ) { num += ( i - ( double ) ( n + 1 ) / 2 ) * ( confirmedDailyIncrements [ i - 1 ] - avgIncrements ) ; den += ( i - ( double ) ( n + 1 ) / 2 ) * ( i - ( double ) ( n + 1 ) / 2 ) ; } return num / den ; }
Estimate the trend line coefficient used to identify the mostly affected regions.
Estimate the trend line coefficient used to identify the mostly affected regions .