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

51.56% Correct | 48.44% Incorrect
Last Solution submitted on Dec 12, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers20

Suggested Problems

More from this Author9

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!