Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-225

Stochastic Complexity

Problem

Return the stochastic complexity of a model in nats: the negative log-likelihood plus half a log term per parameter:

SC = nll_nats + 0.5 * n_params * ln(n_samples)

Assume n_samples >= 1.

Hint

This is the BIC-style penalty expressed in nats instead of bits.

Test cases

case 1
in: [10,2,100]
expected: 14.605170185988092
case 2
in: [0,1,1]
expected: 0
case 3
in: [5,3,8]
expected: 8.119162312519753
case 4
in: [2.5,0,50]
expected: 2.5
Starter codePython
import math
def stochastic_complexity(nll_nats, n_params, n_samples):
    # Your code here
    pass

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