Problem 44684. Basic Monte Carlo Simulation
Input is a matrix including service time and probability of service time. Another input is a random number. Function should transform the random number to service time.
First column of the input1 is service time and second column is probability of that service time.
input1 = [ 2 0.4 5 0.4 9 0.2]
We can calculate cumulative probability and Random Number Assignment with this input,
Service Cumulative Random Number
Time Probability Probability Assignment
2 0.4 0.4 0.000 - 0.400
5 0.4 0.8 0.400 - 0.800
9 0.2 1.0 0.800 - 1.000input2 is a random number between 0 and 1 such as;
input2 = 0.125
Random number can be transformed to service time with the table. Random number (input2) is between first line of random number assignment
0.000 < Random number <= 0.400
as a result
serviceTime = 2
Note: You can assume that the sum of the probabilities will be equal to one.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers26
Suggested Problems
-
Swap the first and last columns
22423 Solvers
-
Find the sum of the elements in the "second" diagonal
1192 Solvers
-
Vector of numbers divisible by 3
152 Solvers
-
666 Solvers
-
Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.
954 Solvers
More from this Author92
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!