class_docstr: Computes a running mean.
  
  In computation, samples can be provided individually or in chunks. A
  "chunk" of size M implies incorporating M samples into a single expectation
  computation at once, which is more efficient than one by one.
  
  `RunningMean` is meant to serve general streaming expectations.
  For a specialized version that fits streaming over MCMC samples, see
  `ExpectationsReducer` in `tfp.experimental.mcmc`.
docstr: Update the `RunningMean` with a new sample.
  
  The update formula is from Philippe Pebay (2008) [1] and is identical to
  that used to calculate the intermediate mean in
  `tfp.experimental.stats.RunningCovariance` and
  `tfp.experimental.stats.RunningVariance`.
  
  Args:
    new_sample: Incoming `Tensor` sample with shape and dtype compatible with
      those used to form the `RunningMean`.
    axis: If chunking is desired, this is an integer that specifies the axis
      with chunked samples. For individual samples, set this to `None`. By
      default, samples are not chunked (`axis` is None).
  
  Returns:
    mean: `RunningMean` updated to the new sample.
  
  #### References
  [1]: Philippe Pebay. Formulas for Robust, One-Pass Parallel Computation of
       Covariances and Arbitrary-Order Statistical Moments. _Technical Report
       SAND2008-6212_, 2008.
       https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2008/086212.pdf
docstr_tok: ["Update","the","`","RunningMean","`","with","a","new","sample",".","The","update","formula","is","from","Philippe","Pebay","(","2008",")","[","1","]","and","is","identical","to","that","used","to","calculate","the","intermediate","mean","in","`","tfp.experimental.stats.RunningCovariance","`","and","`","tfp.experimental.stats.RunningVariance","`",".","Args",":","new_sample",":","Incoming","`","Tensor","`","sample","with","shape","and","dtype","compatible","with","those","used","to","form","the","`","RunningMean","`",".","axis",":","If","chunking","is","desired",",","this","is","an","integer","that","specifies","the","axis","with","chunked","samples",".","For","individual","samples",",","set","this","to","`","None","`",".","By","default",",","samples","are","not","chunked","(","`","axis","`","is","None",")",".","Returns",":","mean",":","`","RunningMean","`","updated","to","the","new","sample",".","#","#","#","#","References","[","1","]",":","Philippe","Pebay",".","Formulas","for","Robust",",","One-Pass","Parallel","Computation","of","Covariances","and","Arbitrary-Order","Statistical","Moments",".","_Technical","Report","SAND2008-6212_",",","2008.","https",":","\/\/prod-ng.sandia.gov\/techlib-noauth\/access-control.cgi\/2008\/086212.pdf"]
code: def update(self, new_sample, axis=None):
      """Update the `RunningMean` with a new sample.
  
      The update formula is from Philippe Pebay (2008) [1] and is identical to
      that used to calculate the intermediate mean in
      `tfp.experimental.stats.RunningCovariance` and
      `tfp.experimental.stats.RunningVariance`.
  
      Args:
        new_sample: Incoming `Tensor` sample with shape and dtype compatible with
          those used to form the `RunningMean`.
        axis: If chunking is desired, this is an integer that specifies the axis
          with chunked samples. For individual samples, set this to `None`. By
          default, samples are not chunked (`axis` is None).
  
      Returns:
        mean: `RunningMean` updated to the new sample.
  
      #### References
      [1]: Philippe Pebay. Formulas for Robust, One-Pass Parallel Computation of
           Covariances and Arbitrary-Order Statistical Moments. _Technical Report
           SAND2008-6212_, 2008.
           https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2008/086212.pdf
      """
      dtype = self.mean.dtype
      new_sample = tf.nest.map_structure(
          lambda new_sample: tf.cast(new_sample, dtype=dtype),
          new_sample,
      )
      if axis is None:
          chunk_n = tf.constant(1, dtype=dtype)
          chunk_mean = new_sample
      else:
          chunk_n = tf.cast(ps.shape(new_sample)[axis], dtype=dtype)
          chunk_mean = tf.math.reduce_mean(new_sample, axis=axis)
      new_n = self.num_samples + chunk_n
      delta_mean = chunk_mean - self.mean
      new_mean = self.mean + chunk_n * delta_mean / new_n
      return RunningMean(new_n, new_mean)
  
imports: import functools
  import math
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.mcmc import diagnostic
  from tensorflow.python.util import nest
label_desc: Use image node_id 6 for calling the RunningMean obj's underlying member method code with example usage: obj.update(new_sample, axis) and returns: RunningMean