1
from __future__ import division
5
__author__ = "Gavin Huttley"
6
__copyright__ = "Copyright 2007-2009, The Cogent Project"
7
__credits__ = ["Gavin Huttley"]
10
__maintainer__ = "Gavin Huttley"
11
__email__ = "Gavin.Huttley@anu.edu.au"
12
__status__ = "Production"
15
def aic(lnL, nfp, sample_size=None):
16
"""returns Aikake Information Criterion
19
- lnL: the maximum log-likelihood of a model
20
- nfp: the number of free parameters in the model
21
- sample_size: if provided, the second order AIC is returned
23
if sample_size is None:
26
assert sample_size > 0, "Invalid sample_size %s" % sample_size
27
correction = sample_size / (sample_size - nfp - 1)
29
return -2* lnL + 2 * nfp * correction
31
def bic(lnL, nfp, sample_size):
32
"""returns Bayesian Information Criterion
35
- lnL: the maximum log-likelihood of a model
36
- nfp: the number of free parameters in the model
37
- sample_size: size of the sample
39
return -2* lnL + nfp * numpy.log(sample_size)