All problems
Prioritized Exponent Alpha
Problem
Recover the prioritization exponent from a desired max/min sampling-probability ratio.
alpha = ln(prob_ratio) / ln(p_max / p_min). Return 0.0 when the inputs are degenerate: p_min <= 0, p_max <= p_min, or prob_ratio <= 1.
Hint
Alpha of 0 samples uniformly; alpha of 1 samples proportional to priority.
Test cases
case 1
in: [1,10,2]
expected: 0.30102999566398114
case 2
in: [1,4,2]
expected: 0.5
case 3
in: [2,2,3]
expected: 0
case 4
in: [1,10,1]
expected: 0
Starter codePython
import math
def prioritized_exponent(p_min, p_max, prob_ratio):
# Your code here
pass4 test cases · run your code against them in the editor