Roulette wheel style selection from Array

Something like the attached image should work.

Silly way to think about it:
Imagine you have a bowl that you pour a random amount of water into, from empty to full, 0-1.
Then each of your weights represents a glass of a certain size, their combined sizes adds up to 1.0.
One by one you then take a glass and remove water from the bowl.
The last glass you need to use to empty the bucket will be your selected one.

For instance, your glasses are the following sizes:
0.4,
0.2,
0.1,
0.3,

Then you randomize a water amount between 0-1. If the number was lower than 0.4 the first glass would empty the bowl.
If the number is between 0.4 and 0.6 the second glass will empty the bowl.
At 0.6-0.7 the third glass will empty it.
And if you poured in between 0.7 and 1, you’ll need the final glass to empty it.