Identification of the Sample Covariance Questions

User Generated

ibff55

Engineering

Description

There is a Computational and Statistical Methods of Electrical Engineering Matlab Project. Its deadline is at the end of the day of May 13, 2021.

Unformatted Attachment Preview

State Dec 2020 rate Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada New Hampshire New Jersey New Mexico New York North Carolina North Dakota Ohio Oklahoma Oregon 11.39 21.93 12.18 9.87 20.45 12.14 20.39 12.51 11.86 10.8 29.14 9.92 12.32 12.69 11.31 12.22 10.53 9.54 16.51 12.73 21.54 16.47 12.87 11.25 9.3 11.02 10.13 11.2 18.74 15.99 12.27 18.23 10.6 9.39 11.8 8.88 10.89 Avg. montly usage 1,201 555 1,014 1,118 532 682 689 950 1,108 1,121 525 949 709 960 867 891 1,112 1,232 562 975 574 637 759 1,206 1,058 857 1,004 890 599 663 640 577 1,079 1,109 874 1,116 911 Pennsylvania Rhode Island South Carolina South Dakota Tennessee Texas Utah Vermont Virginia Washington West Virginia Wisconsin Wyoming United States 13.15 22.59 11.78 11.39 10.41 11.87 10.19 19.04 11.21 9.77 11.41 14.52 10.66 12.8 837 560 1,114 1,044 1,217 1,140 727 549 1,122 973 1,084 674 864 887 The attached Excel file contains a data set on electricity usage across 50 U.S. states in the month of Dec 2020. We want to examine if the electricity charge rate per kWh has correlation with the electricity usage. In practice, there are many other factors that affect the energy usage. We’re only concerned about the electricity charge per kWh here. You should define x as a vector recording the data for the RATE per kWh and y as a vector recording the average number of kWh USAGE across the 50 states. You can save your data into a ‘mat’ file by the MATLAB function save(’data.mat’,’x’,’y’). Next time when you retrieve the data, use the MATLAB function load(’data.mat’). Perform the following tasks: 1. (2pt) Find the (sample) means of the RATE and the USAGE and store them as mX and mY . • (1pt) You may wish to try the MATLAB functions mean(x) and mean(y). • (1pt) Write your own function my mean(x) that takes input as a data vector x and returns its mean mX . This function should provide the following result mX = N 1 X xi N i=1 where N is the length of the data vector x and xi is its ith element. Compare the result you get from my mean(x) and my mean(y) with mean(x) and mean(y) 2. (2pt) Find the (sample) standard deviation of the RATE and the USAGE and store them as stdX and stdY . • (1pt) You may wish to try the MATLAB functions std(x) and std(y). • (1pt) Write your own function my std(x) that takes input as a data vector x and returns its standard deviation mX . This function should provide the following result v u N u 1 X stdX = t (xi − my mean(x))2 . N − 1 i=1 You need to use your own function my mean(x) to get the mean of x. Compare the result you get from my std(x) and my std(y) with std(x) and std(y). 3. (2pt) Determine the median of the RATEs and store it as medianX • (1pt) You may wish to try the MATLAB function median(x). • (1pt) Write your own function my median(x) that takes input as a data vector x and returns its median medianX . You must sort the data vector x in an ascending order into xa first, and then proceed to find the median (the mid point). You must write a script that is usable for both odd and even number of samples. Print your result and compare it with the result obtained from the MATLAB function median(x). 4. (1pt) Illustrate the data in the table using a scatter plot with the horizontal axis representing the RATE and the vertical axis representing the USAGE. From the plot, determine whether the RATE and the USAGE have positive correlation, negative correlation or no correlation. Suggestion: You may wish to try the MATLAB function scatter(x, y). Attach the plot in your report. 5. (1pt) Find the sample covariance of the RATE and the USAGE and store it as covXY . Suggestion: You may wish to try the MATLAB command N/(N − 1) ∗ mean((x − mx). ∗ (y − my)). 1 6. (2pt) Find the correlation coefficient from the sample covariance and the standard deviations of the RATE and the USAGE. Print the obtained correlation coefficient, and determine if the calculation confirms with your observation from the scatter plot. Please turn in your MATLAB script in one section and the results/plots in another section. Attach all in one document. 2
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached explanation and answer. Let me know if you have any questions.This is the final answer. The zip file contains the MATLAB code. I have attached the report as both docx and pdf files. If there are any problems please revert to this chat.

MATLAB SCRIPT:
T=readmatrix('Electricity.xlsx');
x=T(:,2);
y=T(:,3);
save('data.mat','x','y');
load('data.mat');
%Q1
mX = mean(x);
mY = mean(y);
disp("Sample mean
disp("Sample mean
my_mean(x));
disp("Sample mean
disp("Sample mean
my_mean(y));

of x using MATLAB mean function: " + mX);
of x using my_mean function: " +
of y using MATLAB...


Anonymous
Great study resource, helped me a lot.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Related Tags