Cody

Problem 43592. Sample from random roulette

Solution 1227997

Submitted on 10 Jul 2017 by Binbin Qi
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = 1:3; prob = [0.3 0.2 0.5]; assert( (sum(RandomRoulette(x,prob))<1.5*22*1e3) && (sum(RandomRoulette(x,prob))>0.5*22*1e3) && all(ismember(RandomRoulette(x,prob),x)) )

2   Pass
x = 1:4 prob = [0.1 0.2 0.3 0.4]; assert( (sum(RandomRoulette(x,prob))<1.5*30*1e3) && (sum(RandomRoulette(x,prob))>0.5*30*1e3) && all(ismember(RandomRoulette(x,prob),x)) && any(RandomRoulette(x,prob)~=RandomRoulette(x,prob)))

x = 1 2 3 4

Suggested Problems

More from this Author10

Community Treasure Hunt

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

Start Hunting!