Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-411

Rejection Sampling Acceptance Rate

Problem

Rejection sampling with proposal q and bound M accepts a draw with probability 1 / M when the target integrates to one over M q.

Given the bound M > 0, return the expected acceptance rate.

Hint

The tighter the bound, the higher the acceptance.

Test cases

case 1
in: [1]
expected: 1
case 2
in: [2]
expected: 0.5
case 3
in: [10]
expected: 0.1
Starter codePython
def rejection_sampling_acceptance_rate(m):
    # Your code here
    pass

3 test cases · run your code against them in the editor