I want to sample 1 element from values with specified weights:
values=[1,3,6,7,9]
weights=[0.1,0,4,0.3,0.1,0.1]
I need to have access to the element sampled but also to its weight in weights. With the command
using StatsBase
sample(values,Weights(weights))
i only get the element sampled. If for example 7 is sampled, is it possible to have a result like (7,0.1), where 0.1 is the weight of 7 in weights? Thank you!