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.

tfd_covariance(distribution, ...)

Arguments

distribution

The distribution being used.

...

Additional parameters passed to Python.

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).

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.

See also

Examples

# \donttest{ d <- tfd_normal(loc = c(1, 2), scale = c(1, 0.5)) d %>% tfd_variance()
#> tf.Tensor([1. 0.25], shape=(2,), dtype=float32)
# }