How to retrieve a row, biased by populatity?

Daniel Perrett perrettdl at googlemail.com
Tue Aug 21 21:49:50 BST 2012


Sort them by metric and then select the row n where n is a biased
random number between 0 and 1 mutliplied by the number of records and
integer.

The question is then how to generate 'n' and that depends on what you
mean by 'biased'. You need to create a function which maps equally
distributed random numbers between 0 and 1 to numbers distributed in
the way you want, which could be something like n = 1 - rand()^2.

Daniel

On 21 August 2012 21:22, Dave Hodgkinson <davehodg at gmail.com> wrote:
>
> Possibly a perl question. SQL would do...
>
> Given a set of data, say bands, with each having a ranking, either a
> review metric or a sales ranking, how would you retrieve a random
> row, but biased towards the higher ranking?
>


More information about the london.pm mailing list