PIXELBANKv9.1.0
Menu

You are given the estimated inlier ratio and need to calculate how many RANSAC iterations are required for a given success probability.

The formula for required iterations is:

k=log⁑(1βˆ’p)log⁑(1βˆ’wn)k = \frac{\log(1 - p)}{\log(1 - w^n)}

Where:

  • kk = number of iterations needed
  • pp = desired probability of success (e.g., 0.99)
  • ww = inlier ratio (proportion of good correspondences)
  • nn = sample size (points needed for model, e.g., 4 for homography)

This formula comes from the probability that at least one sample contains all inliers after k iterations.

Example:

Input:
inlier_ratio = 0.5
sample_size = 4
success_prob = 0.99
Output:
72
Reasoning:
  1. Probability of all-inlier sample: w^n = 0.5^4 = 0.0625
  2. Probability of at least one outlier: 1 - w^n = 0.9375
  3. Probability of k failures: (1 - w^n)^k
  4. For 99% success: 1 - (1 - w^n)^k >= 0.99 β†’ (1 - w^n)^k <= 0.01 β†’ k * log(1 - w^n) <= log(0.01) β†’ k >= log(0.01) / log(0.9375) β†’ k >= log(1 - 0.99) / log(1 - 0.0625) β†’ k >= -4.605 / -0.0645 β‰ˆ 71.35

Ceiling: k = 72 iterations needed

Constraints:

  • inlier_ratio: proportion of inliers (0 < w < 1)
  • sample_size: number of points per sample (positive integer)
  • success_prob: desired probability of finding good model (default 0.99)
  • Return number of iterations (ceiling of computed value)
  • Handle edge cases: w=1 returns 1, w=0 returns infinity
πŸ”’

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
RANSAC Iteration Count - Easy | PixelBank