tfd_covariance: Covariance.

View source: R/distribution-methods.R

tfd_covarianceR Documentation

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

Other distribution_methods: tfd_cdf(), tfd_cross_entropy(), tfd_entropy(), tfd_kl_divergence(), tfd_log_cdf(), tfd_log_prob(), tfd_log_survival_function(), tfd_mean(), tfd_mode(), tfd_prob(), tfd_quantile(), tfd_sample(), tfd_stddev(), tfd_survival_function(), tfd_variance()

Examples


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


tfprobability documentation built on Sept. 1, 2022, 5:07 p.m.