Page 189 - Artificial Intellegence_v2.0_Class_11
P. 189
Finding the Line of Best Fit
A child’s age and height are recorded for study. Let’s find the line of best fit.
Age(years) Height (cms)
0 20
1 40
2 60
3 80
4 92
5 105
Let us find the best m (slope) and b (y-intercept) that suits the data.
y = mx + b
2
Step 1: For each (x,y), we have to calculate x and xy as shown in the table below:
x y x 2 xy
0 20 0 0
1 40 1 40
2 60 4 120
3 80 9 240
4 92 16 368
5 105 25 525
2
2
Step 2: We have to add all the elements present in x, y, x and xy (which gives us Σx, Σy, Σx and Σxy):
x y x 2 xy
0 20 0 0
1 40 1 40
2 60 4 120
3 80 9 240
4 92 16 368
5 105 25 525
∑x=15 ∑y=397 ∑x =55 ∑xy=1293
2
N = no. of data samples = 6
Step 3: Now we will calculate the slope m:
m = N Σ(xy) – Σx Σy
2
N Σ(x ) – (Σx) 2
6(1293) – 15(397)
=
6(55) – (15) 2
7758 – 5955
= 330 – 225
1803
=
105
= 17.17
Step 4: After calculating the slope now we need to calculate the intercept b:
b = Σy – m Σx
N
397 – 17.17 (15)
=
6
Maths for AI 187

