Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the code here are the numbers but mostly I need ht coda 307 130 350 165 318 150 304 150 302 140 429

image text in transcribedimage text in transcribed

I need the code here are the numbers but mostly I need ht coda

307 130 350 165 318 150 304 150 302 140 429 198 454 220 440 215 455 225 390 190 383 170 340 160 400 150 455 225 113 95 198 95 199 97 200 85 97 88 97 46 110 87 107 90 104 95 121 113 199 90 360 215 307 200 318 210 304 193 97 88 140 90 113 95 232 100 225 105 250 100 250 88 232 100 350 165 400 175 351 153 318 150 383 180 400 170 400 175 258 110 140 72 250 100 250 88 122 86 116 90 79 70 88 76 71 65 72 69 97 60 91 70 113 95 97.5 80 97 54 140 90 122 86 350 165 400 175 318 150 351 153 304 150 429 208 350 155 350 160 400 190 70 97 304 150 307 130 302 140 318 150 121 112 121 76 120 87 96 69 122 86 97 92 120 97 98 80 97 88 350 175 304 150 350 145 302 137 318 150 429 198 400 150 351 158 318 150 440 215 455 225 360 175 225 105 250 100 232 100 250 88 198 95 97 46 400 150 400 167 360 170 350 180 232 100 97 88 140 72 108 94 70 90 122 85 155 107 98 90 350 145 400 230 68 49 116 75 114 91 121 112 318 150 121 110 156 122 350 180 198 95 232 100 250 100 79 67 122 80 71 65 140 75 250 100 258 110 225 105 302 140 350 150 318 150 302 140 304 150 98 83 79 67 97 78 76 52 83 61 90 75 90 75 116 75 120 97 108 93 79 67 225 95 250 105 250 72 250 72 400 170 350 145 318 150 351 148 231 110 250 105 258 110 225 95 231 110 262 110 302 129 97 75 140 83 232 100 140 78 134 96 90 71 119 97 171 97 90 70 232 90 115 95 120 88 121 98 121 115 91 53 107 86 116 81 140 92 98 79 101 83 305 140 318 150 304 120 351 152 225 100 250 105 200 81 232 90 85 52 98 60 90 70 91 53 225 100 250 78 250 110 258 95 97 71 85 70 97 75 140 72 130 102 318 150 120 88 156 108 168 120 350 180 350 145 302 130 318 150 98 68 111 80 79 58 122 96 85 70 305 145 260 110 318 145 302 130 250 110 231 105 225 100 250 98 400 180 350 170 400 190 351 149 97 78 151 88 97 75 140 89 98 63 98 83 97 67 97 78 146 97 121 110 80 110 90 48 98 66 78 52 85 70 91 60 260 110 318 140 302 139 231 105 200 95 200 85 140 88 225 100 232 90 231 105 200 85 225 110 258 120 305 145 231 165 302 139 318 140 98 68 134 95 119 97 105 75 134 95 156 105 151 85 119 97 131 103 163 125 121 115 163 133 89 71 98 68 231 115 200 85 140 88 232 90 225 110 305 130 302 129 351 138 318 135 350 155 351 142 267 125 360 150 89 71 86 65 98 80 121 80 183 77 350 125 141 71 260 90 105 70 105 70 85 65 91 69 151 90 173 115 173 115 151 90 98 76 89 60 98 70 86 65 151 90 140 88 151 90 225 90 97 78 134 90 120 75 119 92 108 75 86 65 156 105 85 65 90 48 90 48 121 67 146 67 91 67 97 67 89 62 168 132 70 100 122 88 107 72 135 84 151 84 156 92 173 110 135 84 79 58 86 64 81 60 97 67 85 65 89 62 91 68 105 63 98 65 98 65 105 74 107 75 108 75 119 100 120 74 141 80 145 76 168 116 146 120 231 110 350 105 200 88 225 85 112 88 112 88 112 88 112 85 135 84 151 90 140 92 105 74 91 68 91 68 105 63 98 70 120 88 107 75 108 70 91 67 91 67 91 67 181 110 262 85 156 92 232 112 144 96 135 84 151 90 140 86 97 52 135 84 120 79 119 82

The attached Excel file contains a data set on the displacements and horsepowers of numerous cars. We want to examine if the displacement of a car has correlation with the the car's horsepower. You should define x as a vector recording the data for the displacements and y as a vector recording the horsepowers. You can load the data from the Excel file as follows: T= readtable('car_dataset.xlsx'); A table2array(T); r should be the first column of A and y should be the second column of A. Perform the following tasks: 1. (2pt) Find the (sample) means of the displacements and the horsepower 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 and returns its mean m.X. This function should provide the following result mX = where N is the length of the data vector and is its ith element. Compare the result you get from my mean(x) and my-mean(y) with mean(x) and mean(y). stdx = Notes: i.) You're not allowed to use MATLAB's built-in sum function here. You have to use "for" loop to calculate the sum, and ii.) Your function must not hard-code a fixed number N for the input, it must work for any data vector 2. N 2. (2pt) Find the (sample) standard deviation of the displacement and the horsepower and store them as stdX and stdY. N-1 NZ . (1pt) You may wish to try the MATLAB functions std(x) and std(y). . (1pt) Write your own function my_std(r) that takes input as a data vector x and returns its standard deviation m.X. This function should provide the following result i=1 N 1 i=1 (x - my.mean(x)). 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 displacements and store it as median X . (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 median X. You must sort the data vector in an ascending order into a 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). Notes: You can use the sort() function in MATLAB to sort your data. 4. (1pt) Illustrate the data in the table using a scatter plot with the horizontal axis representing the displacements and the vertical axis representing the horsepowers. From the plot, determine whether the displacements and the horsepowers 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 displacements and the horsepowers and store it as covXY. Suggestion: You may wish to try the MATLAB command N/(N 1) * mean((x mx). * (y my)). Do not use the built-in MATLAB function to calculate the covariance. 6. (2pt) Find the correlation coefficient from the sample covariance and the standard deviations of the displacement and the horsepower. Print the obtained correlation coefficient, and determine if the calculation confirms with your observation from the scatter plot. The attached Excel file contains a data set on the displacements and horsepowers of numerous cars. We want to examine if the displacement of a car has correlation with the the car's horsepower. You should define x as a vector recording the data for the displacements and y as a vector recording the horsepowers. You can load the data from the Excel file as follows: T= readtable('car_dataset.xlsx'); A table2array(T); r should be the first column of A and y should be the second column of A. Perform the following tasks: 1. (2pt) Find the (sample) means of the displacements and the horsepower 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 and returns its mean m.X. This function should provide the following result mX = where N is the length of the data vector and is its ith element. Compare the result you get from my mean(x) and my-mean(y) with mean(x) and mean(y). stdx = Notes: i.) You're not allowed to use MATLAB's built-in sum function here. You have to use "for" loop to calculate the sum, and ii.) Your function must not hard-code a fixed number N for the input, it must work for any data vector 2. N 2. (2pt) Find the (sample) standard deviation of the displacement and the horsepower and store them as stdX and stdY. N-1 NZ . (1pt) You may wish to try the MATLAB functions std(x) and std(y). . (1pt) Write your own function my_std(r) that takes input as a data vector x and returns its standard deviation m.X. This function should provide the following result i=1 N 1 i=1 (x - my.mean(x)). 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 displacements and store it as median X . (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 median X. You must sort the data vector in an ascending order into a 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). Notes: You can use the sort() function in MATLAB to sort your data. 4. (1pt) Illustrate the data in the table using a scatter plot with the horizontal axis representing the displacements and the vertical axis representing the horsepowers. From the plot, determine whether the displacements and the horsepowers 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 displacements and the horsepowers and store it as covXY. Suggestion: You may wish to try the MATLAB command N/(N 1) * mean((x mx). * (y my)). Do not use the built-in MATLAB function to calculate the covariance. 6. (2pt) Find the correlation coefficient from the sample covariance and the standard deviations of the displacement and the horsepower. Print the obtained correlation coefficient, and determine if the calculation confirms with your observation from the scatter plot

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Retirees Complete Annuity Handbook

Authors: Scot Whiskeyman

1st Edition

8647470052, 979-8647470058

More Books

Students also viewed these Finance questions