|  View source on GitHub | 
Computes a running mean.
Inherits From: AutoCompositeTensor
tfp.experimental.stats.RunningMean(
    num_samples, 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.
| Args | |
|---|---|
| num_samples | A Tensorcounting the number of samples
accumulated so far. | 
| mean | A Tensorbroadcast-compatible withnum_samplesgiving the
current mean. | 
Methods
from_example
@classmethodfrom_example( example )
Initialize an empty RunningMean.
| Args | |
|---|---|
| example | A Tensor.  TheRunningMeanwill accept samples
of the same dtype and broadcast-compatible shape as the example. | 
| Returns | |
|---|---|
| state | RunningMeanrepresenting a stream of no inputs.  Note
that by convention, the supplied example is used only for
initialization, but not counted as a sample. | 
from_shape
@classmethodfrom_shape( shape, dtype=tf.float32 )
Initialize an empty RunningMean.
| Args | |
|---|---|
| shape | Python TupleorTensorShaperepresenting the shape of
incoming samples. | 
| dtype | Dtype of incoming samples and the resulting statistics.
By default, the dtype is tf.float32. Any integer dtypes will be
cast to corresponding floats (i.e.tf.int32will be cast totf.float32), as intermediate calculations should be performing
floating-point division. | 
| Returns | |
|---|---|
| state | RunningMeanrepresenting a stream of no inputs. | 
tree_flatten
tree_flatten()
tree_unflatten
@classmethodtree_unflatten( _, tensors )
update
update(
    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 Tensorsample with shape and dtype compatible with
those used to form theRunningMean. | 
| 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 (axisis None). | 
| Returns | |
|---|---|
| mean | RunningMeanupdated 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