Skip to main content
explain the algorithm i'm trying to replace
Source Link

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$

Basically, I'm trying to find a more efficient way to pick a random order of items that have associated weights that determine their probability of being picked earlier. For example, given the set $X=\{1,2,4\}$if I had items A, B, and a function $f(x)$ as described aboveC with weights 1, 2, and 4, respectively, the current algorithm picks a random number 1-7 and picks A if one calculated $f(1)$it is 1, $f(2)$B if it is 2 or 3, and $f(4)$C if it is 4-7. So, there would beA has a 41/7 chance that $f(4)$ is largestof being 1st, B has a 2/7 chance that $f(2)$ is largest, and 1C a 4/7 chance that $f(1)$. The picked value is largestremoved from the set, and the algorithm repeats with the smaller set.

If I could find a way to instead map these weights to a random value such that ordering them by that value gives the same distribution of selected permutations, that would be cool.

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.

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$

Basically, I'm trying to find a more efficient way to pick a random order of items that have associated weights that determine their probability of being picked earlier. For example, if I had items A, B, and C with weights 1, 2, and 4, respectively, the current algorithm picks a random number 1-7 and picks A if it is 1, B if it is 2 or 3, and C if it is 4-7. So, A has a 1/7 chance of being 1st, B has a 2/7 chance, and C a 4/7 chance. The picked value is removed from the set, and the algorithm repeats with the smaller set.

If I could find a way to instead map these weights to a random value such that ordering them by that value gives the same distribution of selected permutations, that would be cool.

dammit. there was another typo in the title.
Link

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

oops. that lack of a sum in the denominator was kind of a glaring error to overlook.
Source Link

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 $\frac{a}{b}$based on their relative sizes: $P[f(a) \ge f(b)] = \frac{a}{b} \forall\ a,b\ \epsilon \ X$$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.

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 $\frac{a}{b}$: $P[f(a) \ge f(b)] = \frac{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.

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.

better explained the question
Source Link
Loading
Source Link
Loading