Cody

# Problem 87. Indexed Probability Table

Solution 1539837

Submitted on 25 May 2018 by Nicholas Radziul
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 = [4 4 4 4]; p_correct = [0 0 0 1]; assert(isequal(prob_table(x),p_correct))

n = 4 p = [] b = [] p = 0 b = [] p = 0 0 b = [] p = 0 0 0 b = [] b = 4 b = 4 4 b = 4 4 4 b = 4 4 4 4 p = 0 0 0 1

2   Pass
x = [1 2 1 2 1 2 1 2 1 2]; p_correct = [0.5 0.5]; assert(isequal(prob_table(x),p_correct))

n = 10 p = [] b = [] b = 1 b = 1 1 b = 1 1 1 b = 1 1 1 1 b = 1 1 1 1 1 p = 0.5000 b = [] b = 2 b = 2 2 b = 2 2 2 b = 2 2 2 2 b = 2 2 2 2 2 p = 0.5000 0.5000

3   Pass
x = [1 1 2 8]; p_correct = [0.5 0.25 0 0 0 0 0 0.25]; assert(isequal(prob_table(x),p_correct))

n = 4 p = [] b = [] b = 1 b = 1 1 p = 0.5000 b = [] b = 2 p = 0.5000 0.2500 b = [] p = 0.5000 0.2500 0 b = [] p = 0.5000 0.2500 0 0 b = [] p = 0.5000 0.2500 0 0 0 b = [] p = 0.5000 0.2500 0 0 0 0 b = [] p = 0.5000 0.2500 0 0 0 0 0 b = [] b = 8 p = 0.5000 0.2500 0 0 0 0 0 0.2500

4   Pass
x = 1:100; p_correct = 0.01*ones(1,100); assert(isequal(prob_table(x),p_correct))

n = 100 p = [] b = [] b = 1 p = 0.0100 b = [] b = 2 p = 0.0100 0.0100 b = [] b = 3 p = 0.0100 0.0100 0.0100 b = [] b = 4 p = 0.0100 0.0100 0.0100 0.0100 b = [] b = 5 p = 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 6 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 7 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 8 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 9 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 10 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 11 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 12 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 13 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 14 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 15 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 16 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 17 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 18 p = 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 19 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Column 19 0.0100 b = [] b = 20 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 20 0.0100 0.0100 b = [] b = 21 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 21 0.0100 0.0100 0.0100 b = [] b = 22 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 22 0.0100 0.0100 0.0100 0.0100 b = [] b = 23 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 23 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 24 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 24 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 25 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 25 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 26 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 26 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 27 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 27 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 28 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 28 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 29 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 29 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 30 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 30 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 31 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 31 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 32 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 32 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 33 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 33 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 34 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 34 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 35 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 35 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 36 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 36 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 b = [] b = 37 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 36 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Column 37 0.0100 b = [] b = 38 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 19 through 36 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 Columns 37 through 38 0.0100 0.0100 b = [] b = 39 p = Columns 1 through 18 0.0100 0.0100 0.0100 0.0100 0.0...

### Community Treasure Hunt

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

Start Hunting!