All problems
Beta Function Derivative
Problem
The derivative of the beta function with respect to its first argument is dB/da = B(a, b) * (psi(a) - psi(a + b)), where psi is the digamma function.
Given positive integers a and b, compute B(a, b) = Gamma(a)*Gamma(b)/Gamma(a+b) with math.gamma and evaluate digamma with psi(n) = -gamma + H_{n-1}. Return the derivative.
Hint
Differentiating under the integral sign brings down a factor log(t).
Test cases
case 1
in: [1,1]
expected: -1
case 2
in: [2,3]
expected: -0.09027777777777779
case 3
in: [3,3]
expected: -0.02611111111111111
case 4
in: [1,5]
expected: -0.45666666666666667
Starter codePython
def beta_derivative(a, b):
# Your code here
pass4 test cases · run your code against them in the editor