class_docstr: Tracks quantities for numerically stable mean and variance calculation.
class_docstr_tok: ["Tracks","quantities","for","numerically","stable","mean","and","variance","calculation","."]
docstr: Combine unweighted mean and variance parameters, updating accumulator.
docstr_tok: ["Combine","unweighted","mean","and","variance","parameters",",","updating","accumulator","."]
code: def _combine(self, b_count: int, b_mean: float, b_variance: float):
      """Combine unweighted mean and variance parameters, updating accumulator."""
      # In the case of very imbalanced sizes we prefer ratio ~= 0
      a_count, a_mean, a_variance = self.count, self.mean, self.variance
      if b_count > a_count:
          a_count, b_count = b_count, a_count
          a_mean, b_mean = b_mean, a_mean
          a_variance, b_variance = b_variance, a_variance
      new_count = a_count + b_count
      if new_count == 0:
          return
      ratio = b_count / new_count
      new_mean = a_mean + ratio * (b_mean - a_mean)
      new_variance = a_variance + ratio * (
          b_variance
          - a_variance
          + (b_mean - new_mean) * (b_mean - a_mean)
      )
      self.count = new_count
      self.mean = new_mean
      self.variance = new_variance
  
imports: from typing import Optional
  import numpy
label_desc: Use image node_id 4 for calling the MeanVarAccumulator obj's underlying member method code with example usage: obj._combine(b_count, b_mean, b_variance) without return types