All problems
F Distribution PDF Value
Problem
F probability density with d1 numerator and d2 denominator degrees of freedom at x:
f(x) = sqrt((d1 * x)^d1 * d2^d2 / (d1 * x + d2)^(d1 + d2)) / (x * B(d1 / 2, d2 / 2)).
Return 0.0 for nonpositive parameters or x <= 0.
Hint
The Beta function in the denominator can be written with lgamma terms.
Test cases
case 1
in: [1,1,1]
expected: 0.1591549430918952
case 2
in: [2,2,1]
expected: 0.25
case 3
in: [4,2,2]
expected: 0.12799999999999978
case 4
in: [1,1,0]
expected: 0
Starter codePython
import math
def f_pdf_value(d1, d2, x):
# Your code here
pass4 test cases · run your code against them in the editor