Using Find Fit for Linear Regression

## Description

Here, we will produce a scatter plot and linear regression equation for the following data, then plot them on the same set of axes:

(1)
\begin{align} \{ \ (0, 7.1), \ (1, 5.2), \ (2, 2.9), \ (3, 1.05), \ (4, -0.9)\ \} \end{align}

Sage has no default model for find_fit(), so we must set one using other letters as constants, declaring them with var(). In order to perform a linear regression, the model we pass to find_fit() is the standard linear form, $ax + b$.

## Sage Cell

#### Code

dataset = [ (0, 7.1), (1, 5.2), (2, 2.9), (3, 1.05), (4, -0.9) ]
model = a*x + b
find_fit(dataset, model(x))

1 = scatter_plot(dataset)
p2 = plot(-2.015*x + 7.1, -1, 5)
(p1 + p2).show()


## Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

## Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.