Sample from random roulette - MATLAB Cody - MATLAB Central

Problem 43592. Sample from random roulette

Difficulty:Rate
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

52.31% Correct | 47.69% Incorrect
Last Solution submitted on Nov 14, 2024

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
2
4

Problem Recent Solvers21

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!
Go to top of page