# homework 7 class egre 337 1

Create a MATLAB script file, call it “hw7.m”. Write code to perform the following tasks:

- Task 1: (15%) Generate N=10000 values of a continuous random variable X that has a uniform distribution (PDF) between 0.0 and 1.0. Display the histogram of X. Hint: rand(), hist().
- Task 2: (25%) Create a mapping function that takes a value of X and calculates a value of a new random variable Y. The function should be chosen such that Y has a Gaussian (aka normal) distribution (PDF) with a mean of zero and a variance of 0.25. You will find this function with pencil and paper using a method similar to the method seen in the attached examples. Hint: norminv().
- Task 3: (15%) Apply the function from the previous task to the values of X and obtain N values of Y. Display the histogram of Y.
- Task 4: (25%) Create a mapping function that takes a value of X and calculates a value of a new random variable Z. The function should be chosen such that Z has a triangular distribution (PDF) extending from y=0.0 to y=2.0 and with a peak at z=1.0. You will find this function with pencil and paper using a method similar to the method seen in the attached examples.
- Task 5: (15%) Apply the function from the previous task to the values of X and obtain N values of Z. Display the histogram of Z.
- Task 6: (5%) Use comments to clearly label your code sections that address the numbered tasks described above.

Turn in the following: the script file and the calculations you made to find the two mapping functions (scan your work into a PDF).

This is how your code will be tested:

- It will be tested on a computer in one of the engineering labs. Your code should work on one of these computers. If it works on your laptop computer but not in the lab, you will receive zero points.
- I will download the hw7.m script from Blackboard to the desktop.
- I will start MATLAB and navigate to the desktop. I will type “hw7” at the MATLAB command window prompt. At this point your script should perform all the calculations and create all the plots.
- If the code you submit does not run or run with errors, you will receive zero points, no exceptions. By now you should be capable to turn in MATLAB code that is at least valid code.
- If the code executes without errors, it will be graded based on its ability to complete the homework tasks.