/usr/lib/python2.7/dist-packages/cogent/maths/stats/information_criteria.py is in python-cogent 1.9-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from __future__ import division
import numpy
__author__ = "Gavin Huttley"
__copyright__ = "Copyright 2007-2016, The Cogent Project"
__credits__ = ["Gavin Huttley"]
__license__ = "GPL"
__version__ = "1.9"
__maintainer__ = "Gavin Huttley"
__email__ = "Gavin.Huttley@anu.edu.au"
__status__ = "Production"
def aic(lnL, nfp, sample_size=None):
"""returns Aikake Information Criterion
Arguments:
- lnL: the maximum log-likelihood of a model
- nfp: the number of free parameters in the model
- sample_size: if provided, the second order AIC is returned
"""
if sample_size is None:
correction = 1
else:
assert sample_size > 0, "Invalid sample_size %s" % sample_size
correction = sample_size / (sample_size - nfp - 1)
return -2* lnL + 2 * nfp * correction
def bic(lnL, nfp, sample_size):
"""returns Bayesian Information Criterion
Arguments:
- lnL: the maximum log-likelihood of a model
- nfp: the number of free parameters in the model
- sample_size: size of the sample
"""
return -2* lnL + nfp * numpy.log(sample_size)
|