2

I need to generate two positive numbers $a$ and $b$ both $\ge 1$, whose product is bounded $[2..z]$ and both have a limited coverage between 1 and respectively $a.max$ and $b.max$.

The draws should produce and uniform distribution for both numbers.

Bakaburg
  • 2,293
  • 3
  • 21
  • 30
  • This is impossible in general, because the lower limit of $2$ implies $a$ cannot be less than $2/b_{\max}$ and if that strictly exceeds $1,$ $a$ cannot have a uniform distribution on $[1,a_{\max}].$ What restrictions on $a_\max,$ $b_\max,$ and $z$ do you have in mind? – whuber May 07 '20 at 17:58
  • 1
    @whuber: That is why my answer effectively says you need $\min(a_{\max},b_{\max})\ge 2$ – Henry May 08 '20 at 02:15
  • Sorry whuber, more details: I'm making an optimization algorithm for this: https://stats.stackexchange.com/questions/459485/optimization-of-pool-size-and-number-of-tests-for-prevalence-estimation-via-grou which will be used in an official document from the European CDC. The optimization algorithm needs to find the best pool size and number of pools to get prevalence with a good bias/variance. My problem is that the optimization has a low acceptance rate since proposals in which $a \times b > z$ are excluded, with z chosen by the user. – Bakaburg May 08 '20 at 08:50
  • Now I solved it with a prefilter with a "while" loop that take random $a$ and $b$ until the the condition is met and then use those to compute the evaluation score, but I would like to avoid the extra performance bottleneck. So I would like to draw $a$ randomly and than choose $b$ but being sure that the order of this choice doesn't matter – Bakaburg May 08 '20 at 08:52

1 Answers1

0

It is not totally clear to me from the question, but it seems $A$ and $B$ must be uniform over $[1, a_{\max}]$ and $[1, b_{\max}]$ respectively

then one approach might be to

  • generate $A \sim \mathcal U[1, a_{\max}]$

  • set $B = \dfrac{a_{\max}b_{\max} -1 - (b_{\max} -1)A}{a_{\max}-1}$ which will have $B \sim \mathcal U[1, b_{\max}]$ as required

The product $AB$ will then be in $\left[\min(a_{\max},b_{\max}), \dfrac{(a_{\max}b_{\max} -1)^2}{4(a_{\max} -1)(b_{\max} -1)} \right]$ and you can check whether it is indeed a subset of $[2,z]$:

  • If the range of $AB$ is not a subset of $[2,z]$ then no other approach will work, at least without changing the original uniform distributions
  • If the range of $AB$ is a proper subset of $[2,z]$ then there may be other approaches which work too
  • If the range of $AB$ is $[2,z]$ then this (or something which is almost surely equivalent) is the only approach which will work
Henry
  • 30,848
  • 1
  • 63
  • 107
  • Hi! thank you very much! I'm afraid I didn't clarify the problem well, z can be (and usually will be) lower than $a_{max} \times b_{max}$. – Bakaburg May 08 '20 at 08:42
  • @Bakaburg That is not a problem in itself: you need $z \ge \dfrac{(a_{\max}b_{\max} -1)^2}{4(a_{\max} -1)(b_{\max} -1)}$ which is somewhere between $\frac14 a_{\max}b_{\max}$ and $\frac9{16}a_{\max}b_{\max}$ when both $a_{\max}$ and $b_{\max}$ are at least $2$ – Henry May 08 '20 at 11:18