Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Tugasan/Assignment 5 (20 Markah/marks) : Serial No

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Tugasan/Assignment 5 [20 markah/marks]

Jadual di bawah menunjukkan bilangan baris kod (LOC), x, dan masa yang diambil
untuk menyiapkan 5 (lima) aturcara tersebut dalam minit y oleh seorang pengaturcara..
The table below show the number of lines of codes (LOC), x, and the time taken to
finish 5 (five) programmes in minutes, y, by a programmer.

1 2 3 4 5 ∑x ∑ x2
Bilangan baris 10 20 30 40 49 149 5401
kod, x
Line of Codes
(LOC), x
Masa dalam 23 35 41 46 50 195 8051
jam,y
Time in minutes,
y
xy 230 700 1230 1840 2450 6450

a. Andaikan bilangan baris kod, x dan masa dalam minit, y berhubungan secara
linear. Cari garis kuasadua terkecil yang menghubungkan y dengan x.
Assume that the LOC,xand time in minutes, y are linearly related. Find the
least-squares line relating y to x. [5m]

Serial No. Line of Codes Time in X2 xy


(LOC), x minutes , y
1 10 23 100 230
2 20 35 400 700
3 30 41 900 1230
4 40 46 1600 1840
5 49 50 2401 2450
∑x= ∑y= ∑x2 = ∑xy=
149 195 5401 6450

Say, the linear fit be,


y = ax + b

where, a and b are unknown constants to be determined from given data.


Therefore, for least square fitting, we have,

∑y = a∑ x + nb
∑xy = a∑ x 2 + b∑ x

1
Where , n is the number of data(here n= 5)
So, we have
195 = 149a + 5b
6450 = 5401a + 149 b

Solving for a and b,

a = 0.665070774, b= 19.18089092

So, the least square linear fit is:

y = 0.665070774 x + 19. 18089092

1
b. Bina jadual ANOVA bagi regresi linear.
Construct the ANOVA table for the linear regression. [8m]

Fitted y (y) Error,e e2 (yi- y) (yi- y)2


-2.8316 -2.8316 8.017951 -13.1684 173.4068
2.517694 2.517694 6.338781 -6.51769 42.48033
1.866986 1.866986 3.485636 0.133014 0.017693
0.216278 0.216278 0.046776 6.783722 46.01888
-1.76936 -1.76936 3.130631 12.76936 163.0565
∑ yi =¿ ∑e = ∑ e2= ∑ (¿ y i− y )¿= ∑ (¿ y i− y )¿2=
195 7.4 E-08 21.01978 -7.4E-08 424.9802

Fitted y is calculated from the obtained least square linear fit, putting corresponding
value of Line of Codes(LOC),x
y = 0.665070774 x + 19. 18089092
Error e is given by,

e = (y-yi )

Mean, y is given by, y = ∑ yi /5

ANOVA table
df SS MS F test ρ - F crit
value
Regressio 1 424.9802 424.9802/1 = 424.9802/ .004405 10.1280
n 424.9802 7.006593333
(ESS) =60.65432654
Residual 3 21.01978 21.01978/3 =
(RSS) 7.006593333
Total 4 446
(TSS)

1
c. Tentukan sama ada bilangan baris kod (LOC) adalah berguna bagi meramalkan
masa untuk menyiapkan aturcara?
Determine whether the line of codes (LOC) is useful in predicting the time taken
to finish the program?

[7m]
Say, the line of codes (LOC) is not useful in predicting the time taken to finish the
program. Then, we test this hypothesis for statistical significance. So,

H0: The time taken to finish the program is not related to the number of line of codes
(LOC)

H1: The time taken to finish the program is related to the number of line of codes
(LOC)

From ANOVA table, we see that the F ratio for linear regression Ftest is higher than
the Fcrit value at 5% level of significance with (1,3) df . So, we may reject the null
hypothesis and conclude that the time taken to finish the program has linear
relationship to the number of line of codes.

So, yes, the line of codes (LOC) is useful in predicting the time taken to finish the
program.

You might also like