Question: Problem 1a. Write a Matlab code that will allow a user to enter in a critical number between 0 and1, and then track the number
Problem 1a. Write a Matlab code that will allow a user to enter in a critical number between 0 and1, and then track the number of times that a random number must be generated in order to be greater than the critical number. Output the number of attempts that were necessary, and the numbers that were not successful. Be sure that you code is working correctly.(Hint: the command rand will be useful here)
Problem 1b. This problem is similar to Problem #1 but with some extra complications. Write a Matlab code that will allow a user to enter in a critical number between 0 and 1, and then a tolerance that will provide a window. Then track how many tries it takes until the random number falls within the window. For example, if the user selects 0.5 as the critical number and 0.01 as the tolerance, how many times does it take for a random number to be generated that is between 0.49 and 0.51. Again, store the numbers that did not work.
Problem 1c. An extension of the previous problems, but allow the user to enter two separate numbers A and B between zero and 1. Keep track of how many random numbers must be generated until there are two consecutive numbers where: a) the first number is greater than A, and b) the next number is less than B. Be sure to be able to easy track any values or parameters that might be of interest for the user.
PLEASE INSERT COMMENTS TO UNDERSTAND CODE. THANKS!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
