tfp.experimental.stats.RunningCentralMoments
Stay organized with collections
Save and categorize content based on your preferences.
Computes running central moments.
Inherits From: AutoCompositeTensor
tfp.experimental.stats.RunningCentralMoments(
mean_state, exponentiated_residuals, desired_moments
)
RunningCentralMoments
will compute arbitrary central moments in
streaming fashion following the formula proposed by Philippe Pebay
(2008) [1]. For reference, the formula we refer to is the incremental
version of arbitrary moments (equation 2.9). Since the algorithm computes
moments as a function of lower ones, even if not requested, all lower
moments will be computed as well. The moments that are actually returned
is specified by the moment
parameter at initialization. Note, while
any arbitrarily high central moment is theoretically supported,
RunningCentralMoments
cannot guarantee numerical stability for all
moments.
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
Args |
mean_state
|
A RunningMean carrying the running mean estimate.
|
exponentiated_residuals
|
A Tensor representing the sum of exponentiated
residuals. This is a Tensor of shape [max_moment - 1] +
mean_state.mean.shape , which contains the sum of the residuals raised
to the kth power, for all 2 <= k <= max_moment .
|
desired_moments
|
A Python list of integers giving the moments to return.
The maximum element of this list gives the number of moments that
will be computed.
|
Methods
from_example
View source
@classmethod
from_example(
example, moment
)
Initialize an empty RunningCentralMoments
.
Args |
example
|
A Tensor . The RunningCentralMoments will accept
samples of the same dtype and broadcast-compatible shape as
the example.
|
moment
|
Integer or iterable of integers that represent the
desired moments to return.
|
Returns |
state
|
RunningCentralMoments representing 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
View source
@classmethod
from_shape(
shape, moment, dtype=tf.float32
)
Returns an empty RunningCentralMoments
.
Args |
shape
|
Python Tuple or TensorShape representing the shape of
incoming samples.
|
moment
|
Integer or iterable of integers that represent the
desired moments to return.
|
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.int32 will be cast to
tf.float32 ), as intermediate calculations should be performing
floating-point division.
|
Returns |
state
|
RunningCentralMoments representing a stream of no
inputs.
|
moments
View source
moments()
Returns the central moments represented by this RunningCentralMoments
.
Returns |
all_moments
|
A Tensor representing estimates of the requested central
moments. Its leading dimension indexes the moment, in order of those
requested (i.e. in order of self.desired_moments ).
|
tree_flatten
View source
tree_flatten()
tree_unflatten
View source
@classmethod
tree_unflatten(
metadata, tensors
)
update
View source
update(
new_sample
)
Update with a new sample.
Args |
new_sample
|
Incoming Tensor sample with shape and dtype compatible with
those used to form the RunningCentralMoments .
|
Returns |
state
|
RunningCentralMoments updated to include the new sample.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.experimental.stats.RunningCentralMoments\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L530-L707) |\n\nComputes running central moments.\n\nInherits From: [`AutoCompositeTensor`](../../../tfp/experimental/AutoCompositeTensor) \n\n tfp.experimental.stats.RunningCentralMoments(\n mean_state, exponentiated_residuals, desired_moments\n )\n\n`RunningCentralMoments` will compute arbitrary central moments in\nstreaming fashion following the formula proposed by Philippe Pebay\n(2008) \\[1\\]. For reference, the formula we refer to is the incremental\nversion of arbitrary moments (equation 2.9). Since the algorithm computes\nmoments as a function of lower ones, even if not requested, all lower\nmoments will be computed as well. The moments that are actually returned\nis specified by the `moment` parameter at initialization. Note, while\nany arbitrarily high central moment is theoretically supported,\n`RunningCentralMoments` cannot guarantee numerical stability for all\nmoments.\n\n#### References\n\n\\[1\\]: Philippe Pebay. Formulas for Robust, One-Pass Parallel Computation of\nCovariances and Arbitrary-Order Statistical Moments. *Technical Report\nSAND2008-6212* , 2008.\n\u003chttps://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2008/086212.pdf\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mean_state` | A `RunningMean` carrying the running mean estimate. |\n| `exponentiated_residuals` | A `Tensor` representing the sum of exponentiated residuals. This is a `Tensor` of shape `[max_moment - 1] + mean_state.mean.shape`, which contains the sum of the residuals raised to the kth power, for all `2 \u003c= k \u003c= max_moment`. |\n| `desired_moments` | A Python list of integers giving the moments to return. The maximum element of this list gives the number of moments that will be computed. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `from_example`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L613-L629) \n\n @classmethod\n from_example(\n example, moment\n )\n\nInitialize an empty `RunningCentralMoments`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|------------------------------------------------------------------------------------------------------------------------------|\n| `example` | A `Tensor`. The `RunningCentralMoments` will accept samples of the same dtype and broadcast-compatible shape as the example. |\n| `moment` | Integer or iterable of integers that represent the desired moments to return. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `state` | `RunningCentralMoments` representing a stream of no inputs. Note that by convention, the supplied example is used only for initialization, but not counted as a sample. |\n\n\u003cbr /\u003e\n\n### `from_shape`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L579-L611) \n\n @classmethod\n from_shape(\n shape, moment, dtype=tf.float32\n )\n\nReturns an empty `RunningCentralMoments`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `shape` | Python `Tuple` or `TensorShape` representing the shape of incoming samples. |\n| `moment` | Integer or iterable of integers that represent the desired moments to return. |\n| `dtype` | Dtype of incoming samples and the resulting statistics. By default, the dtype is [`tf.float32`](https://www.tensorflow.org/api_docs/python/tf#float32). Any integer dtypes will be cast to corresponding floats (i.e. [`tf.int32`](https://www.tensorflow.org/api_docs/python/tf#int32) will be cast to [`tf.float32`](https://www.tensorflow.org/api_docs/python/tf#float32)), as intermediate calculations should be performing floating-point division. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------|-------------------------------------------------------------|\n| `state` | `RunningCentralMoments` representing a stream of no inputs. |\n\n\u003cbr /\u003e\n\n### `moments`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L682-L700) \n\n moments()\n\nReturns the central moments represented by this `RunningCentralMoments`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `all_moments` | A `Tensor` representing estimates of the requested central moments. Its leading dimension indexes the moment, in order of those requested (i.e. in order of `self.desired_moments`). |\n\n\u003cbr /\u003e\n\n### `tree_flatten`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L571-L573) \n\n tree_flatten()\n\n### `tree_unflatten`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L575-L577) \n\n @classmethod\n tree_unflatten(\n metadata, tensors\n )\n\n### `update`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/stats/sample_stats.py#L631-L680) \n\n update(\n new_sample\n )\n\nUpdate with a new sample.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------------|---------------------------------------------------------------------------------------------------------------|\n| `new_sample` | Incoming `Tensor` sample with shape and dtype compatible with those used to form the `RunningCentralMoments`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------|------------------------------------------------------------|\n| `state` | `RunningCentralMoments` updated to include the new sample. |\n\n\u003cbr /\u003e"]]