Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CMPT 115 - Assignment 3

Read this document in its entirety and carefully before you start anything and understand it. If you have any questions, don't hesitate to email me.

Problem Statement

In this assignment, we will work with linear regression in two independent variables. You are given the following data set that contains 15 data points .

X-values

0.2

-0.6

1.4

1.0

-0.4

1.4

0.6

1.8

-2.0

-1.6

-1.8

-1.6

-0.2

-0.4

1.6

Y-values

-3.0

3.33

1.0

2.67

0.67

0.0

-2.67

1.0

-0.67

-1.33

-1.67

-2.0

-1.33

-3.0

2.33

Z-values

12.46

-13.63

0.26

-7.07

-3.01

4.06

12.19

1.38

-1.89

1.63

2.55

4.26

5.25

11.04

-4.25

We make the assumption that the Z values are dependent on the X and Y values linearly as follows:

z = ax + by + c

We are interested to determine the values of the coefficients a, b, and c in the linear equation above using a linear regression method.

Linear Regression Method

You are provided the formulas to compute the values of the coefficients a, b, and c as shown below.

1 yi 2          1 xizi     −      1 xiyi   (   1 yizi )

1 xi 2   (   1 yi 2 ) −       1 xiyi   2

1 xi 2          1 yizi    −      1 xiyi   (   1 xizi )

1 xi 2   (   1 yi 2 ) −       1 xiyi   2

c = z ax by

The variable n represents the size of the data. For example, in the data set given above n = 15. The                   summations are as described in the lecture. For example,    1 yi 2  means the sum of y12 + y22 + y32 + … + yn2 .  Similarly    1 xi zi  means the sum of x1z1 + x2z2 + x3z3 + ... + xnzn . Finally the bar above a variable indicates the average value. Thus z means the average of the Z values. Similarly for the other terms in the formulas above.

Please use similar ideas (and loops) as in the Week 10 lecture in order to calculate the summations shown       above. So you will basically calculate sum_xx, sum_yy, sum_xy, sum_xz, sum_yz, sum_x, sum_y, and sum_z.   You will then easily calculate ave_x, ave_y, and ave_z. These values then will allow you to compute the values of the coefficients a, b, and c easily. Last but not least, you are required round the computed values of the       coefficients a, b, and c to two decimal places as shown in the lecture.

Starting Your Work

You are given the following program that makes use of the two custom blocks named PrintData and                   PerformRegression. You are required to build these two custom blocks as described in the lectures and submit a working program.

 

Sample Run Outputs

You are given the following sample run output which is obtained using the data set given in the program. You must get the same output when you use the same data set as given in the program above.

Sample Run Output

 

Your Task

You are required to build the PrintData and PerformRegression custom blocks.

Submission Format

You will find a submission link for Assignment 3 on the course Moodle page under Week 10 and you are          required to upload the XML file of your program that contains the given program and your custom blocks . No email submission is allowed for any reason.

Submission Due Date and Time

The due date and time to submit your assignment work is Tuesday 22 November 2022 at 11:55 PM. Moodle will not allow you to upload after this date and time.

Marking

Your program will be tested to see that it performs linear regression correctly and prints correct coefficients.