Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-256

Partition Function Gradient

Problem

Return the gradient of the log-partition function with respect to the natural parameter, which equals the expected sufficient statistic:

E[T] = sum_i t_i * exp(eta * t_i) / Z

Hint

The gradient of A(eta) = ln Z(eta) is the mean of the sufficient statistic.

Test cases

case 1
in: [0,[1,2,3]]
expected: 2
case 2
in: [1,[0,1]]
expected: 0.7310585786300049
case 3
in: [2,[-1,0,1]]
expected: 0.8509370922208681
case 4
in: [-0.5,[0,2]]
expected: 0.5378828427399902
Starter codePython
import math
def partition_gradient(eta, t_values):
    # Your code here
    pass

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