comet_maths.linear_algebra.matrix_calculation.calculate_corr

Contents

comet_maths.linear_algebra.matrix_calculation.calculate_corr#

comet_maths.linear_algebra.matrix_calculation.calculate_corr(MC_y: ndarray, corr_dims: int | None = -99, PD_corr: bool | None = True, dtype: dtype | None = None) ndarray[source]#

Calculate the correlation matrix between the MC-generated samples of output quantities. If corr_dims is specified, this axis will be the one used to calculate the correlation matrix (e.g. if corr_dims=0 and x.shape[0]=n, the correlation matrix will have shape (n,n)). This will be done for each combination of parameters in the other dimensions and the resulting correlation matrices are averaged.

Parameters:
  • MC_y (array) – MC-generated samples of the output quantities (measurands)

  • corr_dims (integer, optional) – set to positive integer to select the axis used in the correlation matrix. The correlation matrix will then be averaged over other dimensions. Defaults to -99, for which the input array will be flattened and the full correlation matrix calculated. When the combined correlation of 2 or more (but not all) dimensions is required, they can be provided as a string containing the different dimension integers, separated by a dot (e.g. “0.2”). When multiple error_correlations should be calculated, they can be provided as a list.

  • PD_corr (bool, optional) – set to True to make sure returned correlation matrices are positive semi-definite, default to True

  • dtype (numpy dtype) – numpy dtype for output variables

Returns:

correlation matrix

Return type:

array