private void addPreviewMeasurementSquaredDiffsToSum ( List < double [ ] > meanMeasurements , List < double [ ] > measurementsSquaredDiffSum , Preview preview , int numEntriesPerPreview ) { List < double [ ] > previewMeasurements = preview . getData ( ) ; // add standard deviation for each measurement in each entry for ( int entryIdx = 0 ; entryIdx < numEntriesPerPreview ; entryIdx ++ ) { double [ ] meanEntry = meanMeasurements . get ( entryIdx ) ; double [ ] previewEntry = previewMeasurements . get ( entryIdx ) ; double [ ] squaredDiffSumEntry ; if ( measurementsSquaredDiffSum . size ( ) > entryIdx ) { squaredDiffSumEntry = measurementsSquaredDiffSum . get ( entryIdx ) ; } else { // initialize sum entry squaredDiffSumEntry = new double [ previewEntry . length ] ; measurementsSquaredDiffSum . add ( squaredDiffSumEntry ) ; } // first measurement is used for indexing // -> simply copy from first preview if ( squaredDiffSumEntry [ 0 ] == 0.0 ) { squaredDiffSumEntry [ 0 ] = previewEntry [ 0 ] ; } // add squared differences for current entry for ( int m = 1 ; m < previewEntry . length ; m ++ ) { double diff = ( meanEntry [ m ] - previewEntry [ m ] ) ; double squaredDiff = diff * diff ; squaredDiffSumEntry [ m ] += squaredDiff ; } } }
Add squared deviations from the mean value from the given Preview to the overall sum .