0

Given a box anchored at $(0, 0)$ and width $w$ and height $h$, I want to randomly select a subbox anchored at $(0, 0)$ with height $w'$ and width $h'$ such that the area of this subbox is a threshold $\alpha \in (0,1]$ times the area of the original box. Or in formulas, I want to select $0 < w' \leq w$, $0 < h' \leq h$, such that $w'h' \geq \alpha wh$.

I do want a uniform sampling of such possible boxes, and I suspect that if I first sample $w'$ and then select $h'$ such that $h' \geq \alpha wh/w'$ that this will not be uniform. Is this the case, and can we find the distribution? If so, how do I choose a proper weight such that this will be the case?

If I select randomly if I first sample $w'$ or $h'$ ($=x$) and then compute the range with the formula above, will this give a uniform sampling?

JT_NL
  • 14,514

1 Answers1

1

Select $h'$ and $w'$ uniformly on their entire range. If they satisfy the constraint, you are done. Otherwise, repeat.

mikado
  • 141
  • Right, will this also be the solution which is the least algorithmically complex? How to ensure it terminates if the shapes are real numbers? – JT_NL Jun 27 '17 at 22:20