I think what he's trying to accomplish is not truly random, but to use the
probability that's indicated in the second field of the table:

1, Aaron, 0.240
> 3, Abe, 0.006
> 13, Adrian, 0.069
>

So there would be a probability of 0.240 that the call returns Aaron, a
probability of 0.006 that it returns Abe, and so on.

I've no clue how to do this in SQL, though, save for the utter stupidity of
creating a table that repeats each name (or UID, saves memory/disk)
1000*probability times, and do a random select on that (or 100* or 10*
depending on how precise you need it). I'd not recommend it, though - it's
gonna be a mess and a huge performance drain.

I suspect this would be better done in code, but I've been out of coding (or
statistics) for too long to give pointers there.


On Mon, Jan 11, 2010 at 3:31 PM, Baron Schwartz <ba...@xaprb.com> wrote:

> Matt,
>
> On Thu, Jan 7, 2010 at 3:10 PM, Matt Neimeyer <m...@neimeyer.org> wrote:
> > What's the best way to select names at random from this but still take
> > into account frequency of use?
>
> Here's the link I usually send clients:
> http://jan.kneschke.de/projects/mysql/order-by-rand/
>
> --
> Baron Schwartz
> Percona Inc: Services and Support for MySQL
> http://www.percona.com/
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=vegiv...@tuxera.be
>
>


-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel

Reply via email to