All problems
Cauchy PDF
Problem
Cauchy probability density with location x0 and scale gamma:
f(x) = 1 / (pi * gamma * (1 + ((x - x0) / gamma)^2)).
Return 0.0 for gamma <= 0.
Hint
Standardize x with z = (x - x0) / gamma first.
Test cases
case 1
in: [0,1,0]
expected: 0.3183098861837907
case 2
in: [0,1,1]
expected: 0.15915494309189535
case 3
in: [0,2,0]
expected: 0.15915494309189535
case 4
in: [0,0,0]
expected: 0
Starter codePython
import math
def cauchy_pdf(x0, gamma, x):
# Your code here
pass4 test cases · run your code against them in the editor