Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-056

BIC Code Length

Problem

Express the BIC score of a model as a code length in bits. Given the natural-log likelihood LL, n samples and k parameters:

len = (k * ln(n) - 2 * LL) / (2 * ln 2)

Assume n > 0.

Hint

Dividing the BIC by 2 ln 2 converts the score into bits.

Test cases

case 1
in: [0,8,2]
expected: 3
case 2
in: [-10,16,1]
expected: 16.426950408889635
case 3
in: [-5,4,2]
expected: 9.213475204444817
case 4
in: [-2,100,3]
expected: 12.851174366440015
Starter codePython
import math
def bic_code_length(log_likelihood, n_samples, n_params):
    # Your code here
    pass

4 test cases · run your code against them in the editor