All problems
Uniform PDF Value
Problem
The uniform density on [a, b] is 1 / (b - a) inside the interval and 0 outside.
Given x, a, and b > a, return the density.
Hint
The density is constant inside and zero outside.
Test cases
case 1
in: [0.5,0,1]
expected: 1
case 2
in: [0,0,2]
expected: 0.5
case 3
in: [-1,0,2]
expected: 0
Starter codePython
def uniform_pdf_value(x, a, b):
# Your code here
pass3 test cases · run your code against them in the editor