human
Least Square Regression Line | Function to calculate b.
sum of array x.
sum of array y.
for sum of product of x and y.
sum of square of x.
Function to find the least regression line.
Finding b.
Calculating a.
Printing regression line.
Statistical data"
Solution in Python:
assistant
#Here is code to least Square Regression Line and the other steps required.
 def calculateB ( x , y , n ) :
	sx = sum ( x )
	sy = sum ( y )
	sxsy = 0
	sx2 = 0
	for i in range ( n ) :
		sxsy += x [ i ] * y [ i ]
		sx2 += x [ i ] * x [ i ]
	b = ( n * sxsy - sx * sy ) / ( n * sx2 - sx * sx )
	return b
def leastRegLine ( X , Y , n ) :
	b = calculateB ( X , Y , n )
	meanX = int ( sum ( X ) / n )
	meanY = int ( sum ( Y ) / n )
	a = meanY - b * meanX
	print ( " Regression ▁ line : " )
	print ( " Y ▁ = ▁ " , ' % .3f ' % a , " ▁ + ▁ " , ' % .3f ' % b , " * X " , sep = " " )
X = [ 95 , 85 , 80 , 70 , 60 ]
Y = [ 90 , 80 , 70 , 65 , 60 ]
n = len ( X )
leastRegLine ( X , Y , n )