question archive San Diego State University – Department of Electrical and Computer Engineering EE300 - Computational and Statistical Methods of Electrical Engineers Spring 2021 - MATLAB Project The attached Excel file contains a data set on electricity usage across 50 U
Subject:SociologyPrice:20.89 Bought3
San Diego State University – Department of Electrical and Computer Engineering EE300 - Computational and Statistical Methods of Electrical Engineers Spring 2021 - MATLAB Project 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 and upload to the Project submission link on Blackboard. Deadline: Saturday, May 15 at 11:59 PM. No late submission is allowed. 2 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 State Dec 2020 rate Avg. montly usage Alabama 11.39 1,201 Alaska 21.93 555 Arizona 12.18 1,014 Arkansas 9.87 1,118 California 20.45 532 Colorado 12.14 682 Connecticut 20.39 689 Delaware 12.51 950 Florida 11.86 1,108 Georgia 10.8 1,121 Hawaii 29.14 525 Idaho 9.92 949 Illinois 12.32 709 Indiana 12.69 960 lowa 11.31 867 Kansas 12.22 891 Kentucky 10.53 1,112 Louisiana 9.54 1,232 Maine 16.51 562 Maryland 12.73 975 Massachusetts 21.54 574 Michigan 16.47 637 Minnesota 12.87 759 Mississippi 11.25 1,206 Missouri 9.3 1,058 Montana 11.02 857 Nebraska 10.13 1,004 Nevada 11.2 890 New Hampshire 18.74 599 Nevada New Hampshire New Jersey New Mexico New York North Carolir North Dakota Ohio Oklahoma Oregon Pennsylvania Rhode Island South Caroli South Dakot Tennessee Texas Utah Vermont Virginia Washington West Virginic Wisconsin Wyoming United State: 11.2 18.74 15.99 12.27 18.23 10.6 9.39 11.8 8.88 10.89 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 890 599 663 640 577 1,079 1,109 874 1,116 911 837 560 1,114 1,044 1,217 1,140 727 549 1,122 973 1,084 674 864 887
Purchased 3 times