Matlab: Simulation Modeling with Continuous Random Variables
Problem DetailsIn this assignment, we will make certain assumptions in order to examine the probability that there will be enough time for a maintenance worker to perform repairs on a signal crossing before the next train arrives on that track. First, we will assume that for a particular signal crossing, the time between arrivals of the next train is a Gaussian (normal) random variable X with µ = 48 minutes and σ = 8 minutes. Next, we will assume that the total time associated with the repair operation consists of the following time interval components:The time for a repair person to receive, notice, and possibly discuss the emergency problem. This information can come from a dispatcher or from a computer. This time will be modeled by a random variable T1 that is defined as T1 = g(X) = 8X, where X has a triangular distribution as in Example 3 of the Chapter 6 Lecture Notes (fX(x) = 2x, 0 ≤ x ≤ 1; 0 otherwise).The time for the repair person to arrive to the location. This time will be modeled by a random variable T2 that is Gaussian, with parameters µ = 18 minutes, σ = 5 minutes.The time to perform the troubleshooting (i.e., problem diagnosis) operation for the activation failure. This will be modeled by an exponential random variable, T3, with parameter λ = .06 minutes.The time to perform the repair (replace parts, etc.). This time will be modeled by a random variable T4 that is uniform with parameters a = 4 minutes and b = 7 minutes.ProcedureYou should only need one MATLAB script program for this assignment, which should be called Assignment2_firstnamelastname.m. Remember to document your MATLAB code.Generate 1000 random values of X. Use the randn function, which generates random values from the Z distribution (i.e., the standardized Gaussian), and adjust each outcome so that it has a Gaussian distribution with µ = 48 (minutes) and σ = 8 (minutes). In using a Gaussian model, the possibility exists of generating some small negative values (because a true Gaussian distribution extends from negative to positive infinity). Therefore, in your code, “truncate” the values generated by ensuring that any negative values are set to zero.Generate 1000 values of T2, using the same approach as used to generate X, and applying the same truncation rule.Generate 1000 values of T3, using the approach from page 68 of the Lecture Notes (see Example 6, Chapter 6) where λ = .06 (minutes).Generate 1000 values of T4 by using the randi function to derive a uniform distribution with endpoints of 4 and 7.Generate 1000 values of T1. First, you will need to perform some hand calculations to derive a mathematical expression that you can then code into your MATLAB program. The steps are as follows:Derive the PDF for T1, using the Theorem 6.2 Addendum formula on page 66 of the Lecture Notes.Derive the CDF of T1.Following the procedure related to Example 6 in Chapter 6 of the Lecture Notes, you need to equate u, which is equal to rand(1), to this CDF.Solve for T1 in your MATLAB code.Define the random variable Y = T1 + T2 + T3 + T4.Determine the probability that the total time associated with the repair operation, Y, is greater than the time between train arrivals, X,i.e., P[Y > X], based on the 1000 simulated values for these two random variables.Compute the minimum, maximum, mean, and standard deviation of Y using the min, max, mean, and std MATLAB functions. Make sure these values can be read off the screen (i.e., don’t suppress their display in the code).PlotsDerive the cumulative probability distribution (CDF) of Y and plot this (simulated) CDF. From this plot, one should be able to estimate P[Y ≤ y], the probability that the total service time duration is less than or equal to some time period y (in minutes). To obtain this CDF, you will need to determine the number of repair times that fall into each 1-minute interval, and let the percentage of these repair times represent the estimated probability of Y being in that interval. A key to being able to generate the data for this plot is to determine how many 1-minute intervals you will need.Finally, plot a histogram for Y using a 3-minute interval as the x-axis interval. On the histogram plot, create a text box within which you should specify the minimum, maximum, mean, and standard deviation of Y, as well as P[Y > X].