Write a program that calculates the equation of a straight line that best fits a given set of data points.

Inputs:n number of data points {xi,yi}, where i = 1, 2,…, n.

Outputs:The equation of the straight line that best fits to the given set of data points:

y=ax+b

where a is the slope of the line, and b is the intercept. The square of the correlation coefficient, r2.

Hint: Use simple linear regression.