what is the answer for question 5.9 ? As function random0 is currently written,
ID: 3624336 • Letter: W
Question
what is the answer for question 5.9 ?
As function random0 is currently written, it will fjil if function seed is not called first. Modify function random0 so that it will function properly with some default seed even if function seed is never called. Write a function that uses function random0 to generate a random value in the range (-1.0.1.0). Make random0 a subfunction of your new function. Write a function that uses function random0 to generate a random value in the range [low. high), where low and high arc passed as calling arguments. Make random0 a private function called by your new function. Dice Simulation It is often useful to be able to simulate the throw of a fair die. Write a MATLAB function dice that simulates the throw of a fair die by returning some random integer between 1 and 6 every time that it is called. (Hint: Call random0 to generate a random number. Divide the possible values out of random0 into six equal intervals and return the number of the interval that a given random value falls into.) Road Traffic Density function random0 produces a number with uniform probability distribution in the range [0.0. 1.0) This function suitable for simulating random events if each outcome has an equal probability of occurring. However, in many events the probability of occurance is not equal for every event, and a uniform probability distribution is not suitable for simulating such events.Explanation / Answer
function dice = roll()
dice = fix(6*rand)+1
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.