Tugasan/Assignment 5 (20 Markah/marks) : Serial No
Tugasan/Assignment 5 (20 Markah/marks) : Serial No
Tugasan/Assignment 5 (20 Markah/marks) : Serial No
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]
∑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
a = 0.665070774, b= 19.18089092
1
b. Bina jadual ANOVA bagi regresi linear.
Construct the ANOVA table for the linear regression. [8m]
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 )
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.