tfp.substrates.jax.stats.auto_correlation
Stay organized with collections
Save and categorize content based on your preferences.
Auto correlation along one axis.
tfp.substrates.jax.stats.auto_correlation(
x,
axis=-1,
max_lags=None,
center=True,
normalize=True,
name='auto_correlation'
)
Given a 1-D
wide sense stationary (WSS) sequence X
, the auto correlation
RXX
may be defined as (with E
expectation and Conj
complex conjugate)
RXX[m] := E{ W[m] Conj(W[0]) } = E{ W[0] Conj(W[-m]) },
W[n] := (X[n] - MU) / S,
MU := E{ X[0] },
S**2 := E{ (X[0] - MU) Conj(X[0] - MU) }.
This function takes the viewpoint that x
is (along one axis) a finite
sub-sequence of a realization of (WSS) X
, and then uses x
to produce an
estimate of RXX[m]
as follows:
After extending x
from length L
to inf
by zero padding, the auto
correlation estimate rxx[m]
is computed for m = 0, 1, ..., max_lags
as
rxx[m] := (L - m)**-1 sum_n w[n + m] Conj(w[n]),
w[n] := (x[n] - mu) / s,
mu := L**-1 sum_n x[n],
s**2 := L**-1 sum_n (x[n] - mu) Conj(x[n] - mu)
The error in this estimate is proportional to 1 / sqrt(len(x) - m)
, so users
often set max_lags
small enough so that the entire output is meaningful.
Note that since mu
is an imperfect estimate of E{ X[0] }
, and we divide by
len(x) - m
rather than len(x) - m - 1
, our estimate of auto correlation
contains a slight bias, which goes to zero as len(x) - m --> infinity
.
Args |
x
|
float32 or complex64 Tensor .
|
axis
|
Python int . The axis number along which to compute correlation.
Other dimensions index different batch members.
|
max_lags
|
Positive int tensor. The maximum value of m to consider (in
equation above). If max_lags >= x.shape[axis] , we effectively re-set
max_lags to x.shape[axis] - 1 .
|
center
|
Python bool . If False , do not subtract the mean estimate mu
from x[n] when forming w[n] .
|
normalize
|
Python bool . If False , do not divide by the variance
estimate s**2 when forming w[n] .
|
name
|
String name to prepend to created ops.
|
Returns |
rxx : Tensor of same dtype as x . rxx.shape[i] = x.shape[i] for
i != axis , and rxx.shape[axis] = max_lags + 1 .
|
Raises |
TypeError
|
If x is not a supported type.
|
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.substrates.jax.stats.auto_correlation\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/jax/stats/sample_stats.py#L45-L216) |\n\nAuto correlation along one axis.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfp.experimental.substrates.jax.stats.auto_correlation`](https://www.tensorflow.org/probability/api_docs/python/tfp/substrates/jax/stats/auto_correlation)\n\n\u003cbr /\u003e\n\n tfp.substrates.jax.stats.auto_correlation(\n x,\n axis=-1,\n max_lags=None,\n center=True,\n normalize=True,\n name='auto_correlation'\n )\n\nGiven a `1-D` wide sense stationary (WSS) sequence `X`, the auto correlation\n`RXX` may be defined as (with `E` expectation and `Conj` complex conjugate) \n\n RXX[m] := E{ W[m] Conj(W[0]) } = E{ W[0] Conj(W[-m]) },\n W[n] := (X[n] - MU) / S,\n MU := E{ X[0] },\n S**2 := E{ (X[0] - MU) Conj(X[0] - MU) }.\n\nThis function takes the viewpoint that `x` is (along one axis) a finite\nsub-sequence of a realization of (WSS) `X`, and then uses `x` to produce an\nestimate of `RXX[m]` as follows:\n\nAfter extending `x` from length `L` to `inf` by zero padding, the auto\ncorrelation estimate `rxx[m]` is computed for `m = 0, 1, ..., max_lags` as \n\n rxx[m] := (L - m)**-1 sum_n w[n + m] Conj(w[n]),\n w[n] := (x[n] - mu) / s,\n mu := L**-1 sum_n x[n],\n s**2 := L**-1 sum_n (x[n] - mu) Conj(x[n] - mu)\n\nThe error in this estimate is proportional to `1 / sqrt(len(x) - m)`, so users\noften set `max_lags` small enough so that the entire output is meaningful.\n\nNote that since `mu` is an imperfect estimate of `E{ X[0] }`, and we divide by\n`len(x) - m` rather than `len(x) - m - 1`, our estimate of auto correlation\ncontains a slight bias, which goes to zero as `len(x) - m --\u003e infinity`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `x` | `float32` or `complex64` `Tensor`. |\n| `axis` | Python `int`. The axis number along which to compute correlation. Other dimensions index different batch members. |\n| `max_lags` | Positive `int` tensor. The maximum value of `m` to consider (in equation above). If `max_lags \u003e= x.shape[axis]`, we effectively re-set `max_lags` to `x.shape[axis] - 1`. |\n| `center` | Python `bool`. If `False`, do not subtract the mean estimate `mu` from `x[n]` when forming `w[n]`. |\n| `normalize` | Python `bool`. If `False`, do not divide by the variance estimate `s**2` when forming `w[n]`. |\n| `name` | `String` name to prepend to created ops. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| `rxx`: `Tensor` of same `dtype` as `x`. `rxx.shape[i] = x.shape[i]` for `i != axis`, and `rxx.shape[axis] = max_lags + 1`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|---------------------------------|\n| `TypeError` | If `x` is not a supported type. |\n\n\u003cbr /\u003e"]]