Uniformly sample subboxes from a box

47 Views Asked by At

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?

1

There are 1 best solutions below

1
On

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