src/main/java/it/uniroma2/dicii/sabd/covidproject/utils/GlobalDataUtils.java
/*
    * Convert a vector of cumulative cases of Covid to a vector of daily increments.
    * Errors in original dataset may cause negative increments. Negative increments are truncated to 0
    * */
Convert a vector of cumulative cases of Covid to a vector of daily increments.
Errors in original dataset may cause negative increments. Negative increments are truncated to 0
Convert a vector of cumulative cases of Covid to a vector of daily increments . Errors in original dataset may cause negative increments . Negative increments are truncated to 0
public static Double[] convertCumulativeToIncrement(int availableDays, String[] csvFields) {
        Double[] dailyCumulativeConfirmed = new Double[availableDays + 1];
        for (int i = 0; i < dailyCumulativeConfirmed.length; i++) {
            dailyCumulativeConfirmed[i] = Double.parseDouble(csvFields[i+8]);
        }
        Double[] confirmedDailyIncrements = new Double[availableDays];
        for (int i = 0; i < availableDays; i++) {
            double dailyIncrements = dailyCumulativeConfirmed[i+1]-dailyCumulativeConfirmed[i];
            confirmedDailyIncrements[i] = (dailyIncrements < 0) ? 0 : dailyIncrements;
        }
        return confirmedDailyIncrements;
    }
public static Double [ ] convertCumulativeToIncrement ( int availableDays , String [ ] csvFields ) { Double [ ] dailyCumulativeConfirmed = new Double [ availableDays + 1 ] ; for ( int i = 0 ; i < dailyCumulativeConfirmed . length ; i ++ ) { dailyCumulativeConfirmed [ i ] = Double . parseDouble ( csvFields [ i + 8 ] ) ; } Double [ ] confirmedDailyIncrements = new Double [ availableDays ] ; for ( int i = 0 ; i < availableDays ; i ++ ) { double dailyIncrements = dailyCumulativeConfirmed [ i + 1 ] - dailyCumulativeConfirmed [ i ] ; confirmedDailyIncrements [ i ] = ( dailyIncrements < 0 ) ? 0 : dailyIncrements ; } return confirmedDailyIncrements ; }
Convert a vector of cumulative cases of Covid to a vector of daily increments.
Convert a vector of cumulative cases of Covid to a vector of daily increments .