Cody

Problem 43592. Sample from random roulette

Given a list of values and their probabilities sample 10,000 values.

Example:

x = [1 2 3 4 5];
prob = [0.2 0.1 0.4 0.1 0.2]

Note that sum(prob)=1. Function output should look like this:

output = [1 4 3 1 4 1 2 3 1 1 1 ... 3 4 2] % a vector of length 10,000

All vectors are meant to be row vectors.

Solution Stats

65.71% Correct | 34.29% Incorrect
Last solution submitted on Nov 06, 2018

Problem Comments

Solution Comments