def AIC(model): """Calculates the Akaike information criterion AIC = 2 k - 2 ln(L) where L is the maximum likelihood function value, k is the number of free parameters. """ # maybe should not have any Offset components? # more than a single pixel, needs iterating, don't do that for now if model.axes_manager.navigation_size: raise NavigationSizeError(model.axes_manager.navigation_size, 0) model._set_p0() # correctly set the parameters (numbers / values) lnL = model._poisson_likelihood_function( model.p0, model.axis.axis[model.channel_switches]) k = len(model.p0) + 1 # +1 for the variance return 2 * k - 2 * lnL
def BIC(model): """Calculates the Bayesian information criterion BIC = -2 * ln(L) + k * ln(n) where L is the maximum likelihood function, k is the number of free parameters, and n is the number of data points (observations) / sample size. """ # maybe should not have any Offset components? # more than a single pixel, needs iterating, don't do that for now if model.axes_manager.navigation_size: raise NavigationSizeError(model.axes_manager.navigation_size, 0) model._set_p0() # correctly set the parameters (numbers / values) lnL = model._poisson_likelihood_function( model.p0, model.axis.axis[model.channel_switches]) n = model.axes_manager.signal_size k = len(model.p0) + 1 return k * np.log(n) - 2. * lnL
def AIC(model): """Calculates the Akaike information criterion AIC = 2 k - 2 ln(L) where L is the maximum likelihood function value, k is the number of free parameters. """ # maybe should not have any Offset components? # more than a single pixel, needs iterating, don't do that for now if model.axes_manager.navigation_size: raise NavigationSizeError(model.axes_manager.navigation_size, 0) model._set_p0() # correctly set the parameters (numbers / values) lnL = model._poisson_likelihood_function( model.p0, model.axis.axis[ model.channel_switches]) k = len(model.p0) + 1 # +1 for the variance return 2 * k - 2 * lnL
def BIC(model): """Calculates the Bayesian information criterion BIC = -2 * ln(L) + k * ln(n) where L is the maximum likelihood function, k is the number of free parameters, and n is the number of data points (observations) / sample size. """ # maybe should not have any Offset components? # more than a single pixel, needs iterating, don't do that for now if model.axes_manager.navigation_size: raise NavigationSizeError(model.axes_manager.navigation_size, 0) model._set_p0() # correctly set the parameters (numbers / values) lnL = model._poisson_likelihood_function( model.p0, model.axis.axis[ model.channel_switches]) n = model.axes_manager.signal_size k = len(model.p0) + 1 return k * np.log(n) - 2. * lnL