I have data like this:
d = (
(701, 1, 0.2),
(701, 2, 0.3),
(701, 3, 0.5),
(702, 1, 0.2),
(702, 2, 0.3),
(703, 3, 0.5)
)
Where (701, 1, 0.2) = (id1, id2, priority)
Is there a pretty way to choose id2 if I know id1, using priority?
Func(701) should return:
1 – in 20% cases
2 – 30%
3 – 50%
Percent will be rough of course
Generate a Cumulative Distribution Function for each ID1 thus:
So you will have
Then generate a random number and search for it in the list.