S
Satoru Logic
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.
In most articles and codes I saw online, a function like this is often named `weighted_random_choice`, which sounds *correct* to me.
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.
The "w" in `wsample` stands for `weighted`, and it randomly selects an element from a container according to relative weights of all the elements.
In most articles and codes I saw online, a function like this is often named `weighted_random_choice`, which sounds *correct* to me.
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.