Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-084

RANSAC Iterations Formula

Problem

Compute the RANSAC iteration count needed for a target success probability.

With w = inlier_ratio ** sample_size, return ceil(log(1 - success_prob) / log(1 - w)). Return 1 when w >= 1, so a perfect inlier ratio needs a single sample.

Hint

Take the ceiling of the log ratio to get an integer iteration count.

Test cases

case 1
in: [0.99,0.5,3]
expected: 35
case 2
in: [0.999,0.8,2]
expected: 7
case 3
in: [0.9,1,2]
expected: 1
case 4
in: [0.5,0.3,4]
expected: 86
Starter codePython
def ransac_iterations(success_prob, inlier_ratio, sample_size):
    # Your code here
    pass

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