Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-250

Gaussian Differential Entropy

Problem

The differential entropy of a Gaussian with standard deviation sigma is 0.5 * ln(2 * pi * e * sigma^2). Return 0.0 when sigma <= 0.

Hint

Plug the variance into the closed-form Gaussian entropy.

Test cases

case 1
in: [1]
expected: 1.4189385332046727
case 2
in: [2]
expected: 2.112085713764618
case 3
in: [0.5]
expected: 0.7257913526447274
case 4
in: [3]
expected: 2.5175508218727822
case 5
in: [0]
expected: 0
Starter codePython
import math


def gaussian_differential_entropy(sigma):
    # Your code here
    pass

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