Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tfd_covariance

Covariance.


Description

Covariance is (possibly) defined only for non-scalar-event distributions. For example, for a length-k, vector-valued distribution, it is calculated as, Cov[i, j] = Covariance(X_i, X_j) = E[(X_i - E[X_i]) (X_j - E[X_j])] where Cov is a (batch of) k x k matrix, 0 <= (i, j) < k, and E denotes expectation.

Usage

tfd_covariance(distribution, ...)

Arguments

distribution

The distribution being used.

...

Additional parameters passed to Python.

Details

Alternatively, for non-vector, multivariate distributions (e.g., matrix-valued, Wishart), Covariance shall return a (batch of) matrices under some vectorization of the events, i.e., Cov[i, j] = Covariance(Vec(X)_i, Vec(X)_j) = [as above] where Cov is a (batch of) k x k matrices, 0 <= (i, j) < k = reduce_prod(event_shape), and Vec is some function mapping indices of this distribution's event dimensions to indices of a length-k vector.

Value

Floating-point Tensor with shape [B1, ..., Bn, k, k] where the first n dimensions are batch coordinates and k = reduce_prod(self.event_shape).

See Also

Examples

d <- tfd_normal(loc = c(1, 2), scale = c(1, 0.5))
d %>% tfd_variance()

tfprobability

Interface to 'TensorFlow Probability'

v0.11.0.0
Apache License (>= 2.0)
Authors
Sigrid Keydana [aut, cre], Daniel Falbel [ctb], Kevin Kuo [ctb] (<https://orcid.org/0000-0001-7803-7901>), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.