AsCorrelationMatrix#

class bayesflow.adapters.transforms.AsCorrelationMatrix(*, cholesky: bool = False)[source]#

Bases: ElementwiseTransform

Constrains neural network predictions of a variable to a valid (symmetric, positive definite, unit diagonal) K x K correlation matrix, using the transforms explained by [1].

The unconstrained representation is a flat vector of K * (K - 1) / 2 entries.

Parameters:
choleskybool, optional

Whether the constrained side of the transform is the lower Cholesky factor, rather than the full correlation matrix. Default is False (use the full correlation matrix).

References

[1] Lewandowski, D., Kurowicka, D., & Joe, H. (2009).

Generating random correlation matrices based on vines and extended onion method. Journal of Multivariate Analysis, 100(9), 1989-2001. https://doi.org/10.1016/j.jmva.2009.04.008

Examples

>>> adapter = bf.Adapter().as_correlation_matrix("corr_x")
get_config() → dict[source]#
forward(data: Tensor, **kwargs) → Tensor[source]#
inverse(data: Tensor, **kwargs) → Tensor[source]#
log_det_jac(data: Tensor, inverse: bool = False, **kwargs) → Tensor[source]#
__call__(data: Tensor, inverse: bool = False, **kwargs) → Tensor#

Call self as a function.

classmethod from_config(config: dict, custom_objects=None)#