Cody

# Problem 44684. Basic Monte Carlo Simulation

Solution 2295645

Submitted on 19 May 2020 by Oliver Warlow
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))

ans = 2

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

ans = 2

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

ans = 5

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

ans = 9

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

ans = 36

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

ans = 1

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

ans = 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

ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6 ans = 2 ans = 3 ans = 4 ans = 5 ans = 6