seq::[−][src] index:: sample_weighted
Randomly sample exactly
amount distinct indices from
return them in an arbitrary order (there is no guarantee of shuffling or
ordering). The weights are to be provided by the input function
which will be called once for each index.
This method is used internally by the slice sampling methods, but it can sometimes be useful to have the indices themselves so this is provided as an alternative.
This implementation uses
O(length + amount) space and
if the “nightly” feature is enabled, or
O(length) space and
O(length + amount * log length) time otherwise.
amount > length.