code: def weighted_incremental_variance(data_weight_pairs):
      mean = 0
      S = 0
      sumweight = 0
      for x, weight in data_weight_pairs:
          temp = weight + sumweight
          Q = x - mean
          R = Q * weight / temp
          S += sumweight * Q * R
          mean += R
          sumweight = temp
      Variance = S / (
          sumweight - 1
      )  # if sample is the population, omit -1
      return Variance
  
imports: from __future__ import division
  import random
  from collections import defaultdict
  from math import log
  from whoosh.compat import xrange, iteritems
label_desc: Use image node_id 7 for calling a global function with example usage: weighted_incremental_variance(data_weight_pairs) and returns: Variance