On 10/10/2012 11:33 PM, Satoru Logic wrote:
I came across a function named `wsample` in a `utils` package of my
workplace recently.

The "w" in `wsample` stands for `weighted`, and it randomly selects
an element from a container according to relative weights of all the
elements.

I agree that wt_select for weighted select might be better for a sample size of 1 ;-).

In most articles and codes I saw online, a function like this is
often named `weighted_random_choice`, which sounds *correct* to me.

Easier to understand, at least the first time, harder to write. Be glad the author did not use 'ws' as would have once been common.

So when I saw this `wsample` function, I considered it a improper
name. Because `wsample`makes me think of `random.sample`, which
returns a list of randomly generated elements, not a element.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to