All problems
AIC from Residuals
Problem
Return the Akaike information criterion computed from the residual sum of squares for a Gaussian model:
AIC = n * ln(RSS / n) + 2k
using the natural logarithm, with n samples and k parameters (including the variance).
Hint
The penalty 2k grows linearly with the number of parameters.
Test cases
case 1
in: [10,100,2]
expected: -226.25850929940455
case 2
in: [100,100,2]
expected: 4
case 3
in: [1,10,1]
expected: -21.025850929940454
case 4
in: [400,100,5]
expected: 148.62943611198907
Starter codePython
import math
def aic_from_rss(rss, n, k):
# Your code here
pass4 test cases · run your code against them in the editor