Cody

# Problem 44684. Basic Monte Carlo Simulation

Solution 1577301

Submitted on 6 Jul 2018 by Martin C.
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
input1 = [ 2 0.4 5 0.4 9 0.2]; input2 = 0.125; serviceTimeCorrect = 2; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.4000 0.8000 1.0000 f = 1 2 3 serviceTime = 2

2   Pass
input1 = [ 2 0.4 5 0.4 9 0.2]; input2 = 0.4; serviceTimeCorrect = 2; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.4000 0.8000 1.0000 f = 1 2 3 serviceTime = 2

3   Pass
input1 = [ 2 0.4 5 0.4 9 0.2]; input2 = 0.474; serviceTimeCorrect = 5; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.4000 0.8000 1.0000 f = 2 3 serviceTime = 5

4   Pass
input1 = [ 2 0.4 5 0.4 9 0.2]; input2 = 0.85; serviceTimeCorrect = 9; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.4000 0.8000 1.0000 f = 3 serviceTime = 9

5   Pass
input1 = [ (45:-1:36)' repmat(0.1,10,1)]; input2 = 0.958; serviceTimeCorrect = 36; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 f = 10 serviceTime = 36

6   Pass
input1 = [ 1 0.5 2 0.5]; input2 = 0.5; serviceTimeCorrect = 1; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.5000 1.0000 f = 1 2 serviceTime = 1

7   Pass
input1 = [ 1 0.5 2 0.5]; input2 = 0.6; serviceTimeCorrect = 2; assert(isequal(rand2ServiceTime(input1,input2),serviceTimeCorrect))

cs = 0.5000 1.0000 f = 2 serviceTime = 2

8   Pass
input1 = [ 2 0.2 3 0.2 4 0.2 5 0.2 6 0.2]; serviceTimeCorrect = 2; for idx = 0.01:0.01:0.2 assert(isequal(rand2ServiceTime(input1,idx),serviceTimeCorrect)) assert(isequal(rand2ServiceTime(input1,idx+0.2),serviceTimeCorrect+1)) assert(isequal(rand2ServiceTime(input1,idx+0.4),serviceTimeCorrect+2)) assert(isequal(rand2ServiceTime(input1,idx+0.6),serviceTimeCorrect+3)) assert(isequal(rand2ServiceTime(input1,idx+0.8),serviceTimeCorrect+4)) end

cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 serviceTime = 3 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 3 4 5 serviceTime = 4 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 4 5 serviceTime = 5 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 5 serviceTime = 6 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 1 2 3 4 5 serviceTime = 2 cs = 0.2000 0.4000 0.6000 0.8000 1.0000 f = 2 3 4 5 ...

### Community Treasure Hunt

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

Start Hunting!