Logarithmic Regression Find Fit

Description

Here, we will generate a logarithmic regression for the following data, and plot the regression and scatter plot of the data:

(1)
\begin{align} \{ \ (1, 2.4446), \ (2, 3.6390), \ (3, 4.6218), \ (4, 5.2089), \ (5, 5.5625) \ \} \end{align}

Sage has no default model, so we must set one using other letters as constants, declaring them with var(). In order to perform a logarithmic regression, the model we pass to find_fit() is the standard logarithmic expression, $aln(bx) + c$.

Sage Cell

Code

var('a b c')
model(x) = a*log(b*x) + c
dataset = [ (1, 2.4446), (2, 3.6390), (3, 4.6218), (4, 5.2089), (5, 5.5625) ]
find_fit(dataset, model)
r(x) = 1.9867*log(2.7353*x) + 0.3939
p1 = plot(r(x), 0, 6, ymin=-1)
p2 = scatter_plot( dataset )
(p1 + p2).show()

Options

Option

Adding axes labels

Code

plot(sin(x),-10,10)

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.

Attribute

Permalink:

Author:

Date: 07 Mar 2019 17:37

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License