public void put ( double x , double y , double w ) { if ( w == 0. ) { return ; } if ( sumWe <= 0. ) { sumX = x * w ; sumY = y * w ; sumWe = w ; return ; } // Delta to previous mean final double deltaX = x * sumWe - sumX ; final double deltaY = y * sumWe - sumY ; final double oldWe = sumWe ; // Incremental update sumWe += w ; final double f = w / ( sumWe * oldWe ) ; // Update sumXX += f * deltaX * deltaX ; sumYY += f * deltaY * deltaY ; // should equal weight * deltaY * neltaX! sumXY += f * deltaX * deltaY ; // Update means sumX += x * w ; sumY += y * w ; }
Put a single value into the correlation statistic .