download problem

Debarshi Ray debarshi.ray at
Thu May 15 14:08:58 UTC 2008

> One thing MM would benefit from would be a weighted sampler.
> [...]
> What I need is a replacement for random.shuffle() that takes a list of
> tuples: (something, weight).  And returns a list of somethings that
> was generated with a statistical sampling based on weight.
> Now, this is _probably_ a simple thing to do; my college number theory
> professor would mock me for having not "just done it" myself, but hey
> - I took that class _twice_ before passing it - I don't trust my
> skills in this area to get it right.

Here is a crude approach:

Say A, B and C are mirrors having bandwidth of x,y and z Mbps
respectively. So lets have an array which has: A, A, A... (x times),
B, B, B... (y times), C, C, C... (z times), and then generate a random
number within [0, x+y+z] and use that as an index to fetch a mirror
from the array.

Happy hacking,
"From what we get, we can make a living; what we give, however, makes a life."
 -- Arthur Ashe

More information about the Fedora-infrastructure-list mailing list