Re: download problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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,
Debarshi
-- 
"From what we get, we can make a living; what we give, however, makes a life."
 -- Arthur Ashe

_______________________________________________
Fedora-infrastructure-list mailing list
Fedora-infrastructure-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-infrastructure-list

[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux