code: protected static void incrementalUpdateMean(double[] mean, NumberVector vec, int newsize, double op) {
      if(newsize == 0) {
        return; // Keep old mean
      }
      // Note: numerically stabilized version:
      VMath.plusTimesEquals(mean, VMath.minusEquals(vec.toArray(), mean), op / newsize);
    }
docs: Compute an incremental update for the mean.
  
  @param mean Mean to update
  @param vec Object vector
  @param newsize (New) size of cluster
  @param op Cluster size change / Weight change