class_docstr: Tracks quantities for numerically stable mean and variance calculation.
class_docstr_tok: ["Tracks","quantities","for","numerically","stable","mean","and","variance","calculation","."]
docstr: Updates a WeightedMeanVarAccumulator with a batch of values and weights.
  
  Args:
    array: An ndarray with numeric type.
    weights: An weight array. It must have the same shape as `array`.
  
  Raises:
    ValueError: If weights and values have incompatible shapes, or if called
    on an unweighted accumulator.
docstr_tok: ["Updates","a","WeightedMeanVarAccumulator","with","a","batch","of","values","and","weights",".","Args",":","array",":","An","ndarray","with","numeric","type",".","weights",":","An","weight","array",".","It","must","have","the","same","shape","as","`","array","`",".","Raises",":","ValueError",":","If","weights","and","values","have","incompatible","shapes",",","or","if","called","on","an","unweighted","accumulator","."]
code: def update(self, array: np.ndarray, weights: np.ndarray):
      """Updates a WeightedMeanVarAccumulator with a batch of values and weights.
  
      Args:
        array: An ndarray with numeric type.
        weights: An weight array. It must have the same shape as `array`.
  
      Raises:
        ValueError: If weights and values have incompatible shapes, or if called
        on an unweighted accumulator.
      """
      array = array.astype(np.float64)
      combined_count = array.size
      if combined_count == 0:
          return
      if not np.array_equal(array.shape, weights.shape):
          raise ValueError("incompatible weights shape")
      weights = weights.astype(np.float64)
      weights_mean = np.mean(weights)
      if weights_mean == 0:
          self.count += combined_count
          return
  
      mean = np.sum(weights * array) / (combined_count * weights_mean)
      variance = np.sum(weights * (array - mean) ** 2) / (
          combined_count * weights_mean
      )
      self._combine(combined_count, mean, variance, weights_mean)
  
imports: from typing import Optional
  import numpy
label_desc: Use image node_id 2 for calling the WeightedMeanVarAccumulator obj's underlying member method code with example usage: obj.update(array, weights) without return types