calc_AICc_likelihood#

mufasa.UltraCube.calc_AICc_likelihood(ucube, ncomp_A, ncomp_B, ucube_B=None, multicore=True, expand=0, planemask=None)[source]#

Calculate the relative likelihood of two models based on their AICc values.

This function computes the logarithmic relative likelihood of model A compared to model B, given their corrected Akaike Information Criterion (AICc) values. It can optionally use a second UltraCube instance for comparisons.

Parameters:
  • ucube (UltraCube) – An instance of the UltraCube class containing the spectral data, fitted models, and associated parameters for model A.

  • ncomp_A (int) – Number of components in model A.

  • ncomp_B (int) – Number of components in model B.

  • ucube_B (UltraCube, optional) – An optional second UltraCube instance for model B. If provided, AICc values for both models are calculated independently, and a common mask is used. Default is None.

  • multicore (bool, optional) – Whether to enable parallel processing. Default is True.

  • expand (int, optional) – Number of spectral channels to expand the region where AICc values are calculated. Default is 0.

  • planemask (numpy.ndarray, optional) – A 2D spatial boolean array specifying which pixels to calculate the relative likelihood for. If None, all pixels are considered. Default is None.

Returns:

lnk – A 2D array containing the logarithmic relative likelihood of model A compared to model B.

Return type:

numpy.ndarray

Notes

  • The likelihood is derived from the difference in AICc values:

    \[\ln(\mathcal{L}_A / \mathcal{L}_B) = (AICc_B - AICc_A) / 2\]

    where \(\mathcal{L}_A\) and \(\mathcal{L}_B\) are the likelihoods of models A and B.

  • If ucube_B is provided, the models are compared over their common mask, and the AICc values are recalculated fresh.

  • This function handles mismatches in sample size (NSamp) by resetting and updating model masks.

  • Currently, the expand argument is only used if ucube_B is provided

Raises:

ValueError – If the required AICc values for the models cannot be calculated due to missing data or invalid masks.