Skip to main content
3 of 5
oops. that lack of a sum in the denominator was kind of a glaring error to overlook.

Is there an f(x) such that P[f(a) >= f(b)] = a/b given a set of possible values for a and b?

I need a function $f(x)$ such that given a set of values $X=\{x1, x2, ...\}$ and a function $rand()$ that returns a value between 0 and 1, $f(x)$ returns a value that increases with x such that the probability that $f(a)$ returns a value greater than $f(b)$ is based on their relative sizes: $P[f(a) \ge f(b)] = \frac{a}{a+b} \forall\ a,b\ \epsilon \ X$

For example, given the set $X=\{1,2,4\}$ and a function $f(x)$ as described above, if one calculated $f(1)$, $f(2)$, and $f(4)$, there would be a 4/7 chance that $f(4)$ is largest, 2/7 chance that $f(2)$ is largest, and 1/7 chance that $f(1)$ is largest.