Cody

Solution 454627

Submitted on 13 Jun 2014 by Clemens Giegerich
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
%% probs = rand; while sum(probs) < 1 a = rand; if a + sum(probs) > 1 probs = [probs 1-sum(probs)]; break; else probs = [probs a]; end end states = 1:length(probs); for i = 1:100 y{i,1} = select_state(probs); [nelements,centers] = hist(y{i},states); probs_result{i} = nelements/length(y{i}); error(i,1) = sum(abs(probs-probs_result{i})); end assert(mean(error) <= 0.05 & mean(error) > 0);