NetLogo 7.0.0-beta2:

rnd:weighted-n-of-list-with-repeats

rnd:weighted-n-of-list-with-repeats size list anonymous-reporter

Reports a list of the given size randomly chosen from the list of candidates, with repeats.

The probability of each item being picked is proportional to the weight given by the anonymous-reporter for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the Anonymous Procedures section of the Programming Guide for more details.)

It is not an error for size to be greater than the size of the list of candidates, but there has to be at least one candidate.

If, at some point during the selection, there remains only candidates with a weight of 0.0, they all have an equal probability of getting picked.

If all weights are 0.0, each candidate has an equal probability of being picked.

The items in the resulting list appear in the same order that they appeared in the list of candidates. (If you want them in random order, use shuffle on the result).

Example:

let pairs [ [ "A" 0.2 ] [ "B" 0.8 ] ]
print map first rnd:weighted-n-of-list-with-repeats 25 pairs [ [p] -> last p ]

This should print a list of 25 As and Bs, with roughly four times as many Bs than As.

Take me to the full Rnd Extension Dictionary