Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-055

MDL Two-Part Code

Problem

Compute the two-part MDL description length in bits: the negative log-likelihood plus one log2(n) term per parameter:

DL = NLL + k * log2(n)

Here n is the number of samples and k the number of parameters.

Hint

Each parameter costs log2(n) bits to encode in the two-part code.

Test cases

case 1
in: [10,8,2]
expected: 16
case 2
in: [0,1,1]
expected: 0
case 3
in: [5,16,3]
expected: 17
case 4
in: [8,10,2]
expected: 14.643856189774723
Starter codePython
import math
def mdl_two_part(nll_bits, n_samples, n_params):
    # Your code here
    pass

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