# Assignment 1: CS 215 Solved

30.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` zip` solution files instantly, after Payment

## Description

Questions:
1. Given n values {xi}
ni=1 having mean Âµ, median Î½ and standard deviation Ïƒ, prove that |Âµ âˆ’ Î½| â‰¤ Ïƒ. Assume
n is even. [10 points]

2. Consider four sets of n values each: {xi}
n
i=1, {yi}
n
i=1, {zi}
n
i=1, {wi}
n
i=1. Consider for all i, 1 â‰¤ i â‰¤ n, we have
zi = axi + b and wi = cyi + d where a 6= 0, c 6= 0. Here a, b, c, d are constants. Then prove that r(z, w) =
Â±r(x, y) where r is the correlation coefficient. Comment on when the we would have r(z, w) = r(x, y) and
when we would have r(x, y) = âˆ’r(z, w). [10 points]

3. Given n distinct values {xi}
n
i=1 with mean Âµ and standard deviation Ïƒ, prove that for all i, we have |xiâˆ’Âµ| â‰¤
Ïƒ
âˆš
n âˆ’ 1. [10 points]
In the following problems, you can use the mean, median and standard deviation functions from MATLAB.

4. Generate a sine wave in MATLAB of the form y = 5 sin(2x + Ï€/3) where x ranges from -10 to 10 in steps of
0.02. Now randomly select 40 values in the array y (using MATLAB function â€˜randpermâ€™) and corrupt them
by adding random values from 5 to 10 using the MATLAB function â€˜randâ€™. This will generate a corrupted
sine wave which we will denote as z. Now your job is to filter z using the following steps.
â€¢ Create a new array ymedian to store the filtered sine wave.
â€¢ For a value at index i in z, consider a neighborhood N(i) consisting of z(i), 8 values to its right and 8
values to its left. For indices near the left or right end of the array, you may not have 8 neighbors in
one of the directions. In such a case, the neighborhood will contain fewer values.
1
â€¢ Set ymedian(i) to the median of all the values in N(i). Repeat this for every i.
This process is called as â€˜moving median filteringâ€™, and will produce a filtered signal in the end. Repeat the
entire procedure described here using the arithmetic mean instead of the median. This is called as â€˜moving
average filteringâ€™. Plot the original (i.e. clean) sine wave y, the corrupted sine wave z and the filtered sine
wave using mean and median on the same figure in different colors. Introduce a legend on the plot (find
out how to do this in MATLAB). Include an image of the plot in your report. Now compute and print the
relative mean squared error between each result and the original clean sine wave. The relative mean squared
error between y and its estimate Ë†y is defined as
P
i
(yi âˆ’ yË†i)
2
P
i
y
2
i
.
Now repeat all the steps above when the random values to corrupt the sine wave lay in a range from 100 to
120, and include the plot of the sine waves in your report, and write down the relative mean square error
values.
Which method (median or arithmetic mean) produced better relative mean squared error? Why? Explain