Solved by phan_phan in post #4 
              
              
                Hi ! 
If you want to do : 
a_numpy = np.array([1, 2, 3, 4])
p_numpy = np.array([0.1, 0.1, 0.1, 0.7])
b_numpy = np.random.choice(a_numpy, p=p_numpy)

You can use torch.multinomial : 
a = torch.tensor([1, 2, 3, 4])
p = torch.tensor([0.1, 0.1, 0.1, 0.7])
index = p.multinomial(num_samples=1, replacement…