# Pick random value based on list of probabilities

I'm pretty sure this must have been asked before, but I can not find the duplicate.

Given a list of values with their probabilities

probabilities = {{1500, 0.037000000000000005}, {2500, 0.027000000000000003}, {3500,
0.039}, {4500, 0.07400000000000001}, {5500, 0.073}, {6500,
0.08199999999999999}, {7500, 0.092}, {8500, 0.096}, {9500,
0.095}, {10500, 0.09}, {11500, 0.078}, {12500, 0.065}, {13500,
0.051}, {14500, 0.037000000000000005}, {15500,
0.026000000000000002}, {16500, 0.017}, {17500, 0.01}, {18500,
0.006}, {19500, 0.003}, {20500, 0.002}};


How can I draw a random value from this list with the given probability? I'd wager a guess that you could somehow model a PDF based on this and use it with functions like RandomVariate[].

• Look at RandomChoice. Commented Sep 17, 2023 at 19:01
• @ChrisK That was what I was looking for thanks! If you'd like the points, post it as an answer (no code example needed) Commented Sep 17, 2023 at 19:05

SeedRandom[1];

RandomChoice[WeightedData @@ Transpose[probabilities], 5]

{12500, 4500, 12500, 5500, 5500}


Alternatively,

SeedRandom[1];

RandomChoice[#2 -> # & @@ Transpose[probabilities], 5]

{12500, 4500, 12500, 5500, 5500}