List:General Discussion« Previous MessageNext Message »
From:Johan De Meersman Date:January 11 2010 2:50pm
Subject:Re: Probability Selects
View as plain text  
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 <baron@stripped> wrote:

> Matt,
> On Thu, Jan 7, 2010 at 3:10 PM, Matt Neimeyer <matt@stripped> 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:
> --
> Baron Schwartz
> Percona Inc: Services and Support for MySQL
> --
> MySQL General Mailing List
> For list archives:
> To unsubscribe:

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

Probability SelectsMatt Neimeyer7 Jan
  • RE: Probability SelectsDaevid Vincent7 Jan
  • Re: Probability SelectsTom Worster8 Jan
  • Re: Probability SelectsBaron Schwartz11 Jan
    • Re: Probability SelectsJohan De Meersman11 Jan