Function for picking an item out of a mapping based on the given weights.
The mapping of item to weight
A randomly picked item according to the weights
An error if the input map is empty
Function for picking an item out of a mapping based on the given weights.