A neat implementation of randsrc in the communication system toolbox
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);
|
116 Solvers
Matrix with different incremental runs
106 Solvers
202 Solvers
Determine if input is a Narcissistic number
120 Solvers
3064 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!