I'd like to select a random record from a table, but I'd like to weight it.
For example, let's say I have a table like:
data1 data2 weight
----------------------------------------
1 2 3.44
3 4 0.94
5 6 1.00
7 8 2.00
I would like to select (data1,data2) from a random record, but I'd like (1,2)
to be 3.44 times as likely as (5,6). I would also like (7,8) to be 2 times as
likely as (5,6), and (1,2) to be 1.72 times as likely as (7,8).
Does that make mathematical sense? I think I can do it if weight is an integer
(but it would be a really bad hack), but I can't think of a nice way with
fractions.
Thanks,
Jeff Davis