sbi.analysis.conditional_corrcoeff

sbi.analysis.conditional_corrcoeff#

conditional_corrcoeff(density, limits, condition, subset=None, resolution=50)[source]#

Returns the conditional correlation matrix of a distribution.

To compute the conditional distribution, we condition all but two parameters to values from condition, and then compute the Pearson correlation coefficient \(\rho\) between the remaining two parameters under the distribution density. We do so for any pair of parameters specified in subset, thus creating a matrix containing conditional correlations between any pair of parameters.

If condition is a batch of conditions, this function computes the conditional correlation matrix for each one of them and returns the mean.

Parameters:
  • density (Any) – Probability density function with .log_prob() function.

  • limits (Tensor) – Limits within which to evaluate the density.

  • condition (Tensor) – Values to condition the density on. If a batch of conditions is passed, we compute the conditional correlation matrix for each of them and return the average conditional correlation matrix.

  • subset (List[int] | None) – Evaluate the conditional distribution only on a subset of dimensions. If None this function uses all dimensions.

  • resolution (int) – Number of grid points on which the conditional distribution is evaluated. A higher value increases the accuracy of the estimated correlation but also increases the computational cost.

Return type:

Tensor

Returns: Average conditional correlation matrix of shape either (num_dim, num_dim) or (len(subset), len(subset)) if subset was specified.