How to determine probabilities according to a position on a list

52 Views Asked by At

I'm working on a SQL system in which i have to retrieve a "winning" user from a users list. The winner is determined randomly, but the users should have more chances if their coeficient number is lower. This coeficient number is an auto-incremental number asigned to each of the users.

So, this said, this is an example of what i have:

User. | Coeficient.

user1 | 1

user2 | 2

user3 | 3

user4 | 4

I would like to the users to have more chances in an inverse proportional way to its coeficient number. Something like User1 40%, user2 30%, user3 20% and user4 10%, no need to exactly be that proportion though. Please note that only one user wins for each draw that is made and the amount of users can vary.

I've been trying to figure out a mathematical ecuation or process to achieve this or similar but couldn't.

If you know a way to achieve this or a technique that serves as guide it would help me a lot.

Thanks and sorry for the bad english!

1

There are 1 best solutions below

0
On

Since the probability grows linearly, the cumulative distribution function grows quadratically. You can draw from any distribution by applying the inverse of its cumulative distribution function to a value $u$ uniformly drawn from $[0,1]$. Thus you might want to give the prize to user $n-\lfloor n\sqrt u\rfloor$ (where $n$ is the number of users).