All problems
Order Statistic Density Value
Problem
Probability density of the k-th order statistic of n independent Uniform(0, 1) variables at x:
f_(k)(x) = n * C(n - 1, k - 1) * x^(k - 1) * (1 - x)^(n - k).
Return 0.0 when x is outside [0, 1] or k is outside 1..n.
Hint
Pick which observation lands at x, then order the rest around it.
Test cases
case 1
in: [1,1,0.5]
expected: 1
case 2
in: [2,1,0.5]
expected: 1
case 3
in: [2,2,0.5]
expected: 1
case 4
in: [3,2,0.25]
expected: 1.125
case 5
in: [3,4,0.5]
expected: 0
Starter codePython
import math
def order_stat_density_value(n, k, x):
# Your code here
pass5 test cases · run your code against them in the editor