class_docstr: Tracks values for numerically stable mean and covariance calculation.
class_docstr_tok: ["Tracks","values","for","numerically","stable","mean","and","covariance","calculation","."]
docstr: Combine unweighted mean and covariance parameters, updating accumulator.
docstr_tok: ["Combine","unweighted","mean","and","covariance","parameters",",","updating","accumulator","."]
code: def _combine(
      self,
      b_count: int,
      b_mean: Optional[np.ndarray],
      b_covariance: Optional[np.ndarray],
  ):
      """Combine unweighted mean and covariance parameters, updating accumulator."""
      a_count, a_mean, a_covariance = (
          self.count,
          self.mean,
          self.covariance,
      )
      new_count = a_count + b_count
      if new_count == a_count:
          return
      elif new_count == b_count:
          # Avoid division by zero, which would happen otherwise if b_count=1
          new_mean = b_mean
          new_covariance = b_covariance
      else:
          if a_mean is None:
              a_mean = np.zeros((np.shape(b_mean)), dtype=np.float64)
          if a_covariance is None:
              a_covariance = np.zeros(
                  (np.shape(b_covariance)), dtype=np.float64
              )
          ratio = b_count / new_count
          new_mean = a_mean + ratio * (b_mean - a_mean)
          new_covariance = (
              a_covariance * (a_count - 1)
              + b_covariance * (b_count - 1)
              + (
                  np.outer(
                      (a_mean - new_mean), (a_mean - new_mean) * a_count
                  )
              )
              + (
                  np.outer(
                      (b_mean - new_mean), (b_mean - new_mean) * b_count
                  )
              )
          ) / (new_count - 1)
      self.count = new_count
      self.mean = new_mean
      self.covariance = new_covariance
  
imports: from typing import Optional
  import numpy
label_desc: Use image node_id 4 for calling the MeanCovAccumulator obj's underlying member method code with example usage: obj._combine(b_count, b_mean, b_covariance) without return types