All problems
Partition Function
Problem
Return the exponential-family partition function for a single sufficient statistic:
Z(eta) = sum_x exp(eta * t_x)
where t_values lists the statistic values over the support.
Hint
The partition function normalizes the exponential family distribution.
Test cases
case 1
in: [0,[1,2,3]]
expected: 3
case 2
in: [1,[0,1]]
expected: 3.718281828459045
case 3
in: [2,[-1,0,1]]
expected: 8.524391382167263
case 4
in: [-0.5,[0,2]]
expected: 1.3678794411714423
Starter codePython
import math
def partition_function(eta, t_values):
# Your code here
pass4 test cases · run your code against them in the editor