%% This document created by Scientific Notebook (R) Version 3.0


\documentclass[12pt,thmsa]{article}
\usepackage{amssymb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{makeidx}
\usepackage{sw20jart}

%TCIDATA{TCIstyle=article/art4.lat,jart,sw20jart}

%TCIDATA{<META NAME="ViewSettings" CONTENT="31">}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="Title" CONTENT="Curve Fitting">}
%TCIDATA{Created=Mon Aug 19 14:52:24 1996}
%TCIDATA{LastRevised=Thu Feb 13 16:52:39 1997}
%TCIDATA{Language=American English}
%TCIDATA{CSTFile=MathHelp.cst}
%TCIDATA{<LINK REL="begin" HREF="DM11-1.tex">}
%TCIDATA{<LINK REL="contents" HREF="DM0-0.tex">}
%TCIDATA{<LINK REL="end" HREF="DM11-9.tex">}
%TCIDATA{<LINK REL="index" HREF="DMIndex.tex">}
%TCIDATA{<LINK REL="next" HREF="DM11-9.tex">}
%TCIDATA{<LINK REL="parent" HREF="DM11.tex">}
%TCIDATA{<LINK REL="previous" HREF="DM11-6.tex">}
%TCIDATA{<LINK REL="top" HREF="DM0-0.tex">}

\input{tcilatex}
\begin{document}


\section{Curve Fitting 
\index{Curve fitting@Curve fitting}\label{Curve fitting}\label%
{Statistics, fit curve to data}}

With \textsl{Scientific Notebook}, you have the tools to do general curve
fitting in an intuitive manner. From the \textsf{Statistics} submenu, choose 
\textsf{Fit Curve to Data} and 
\index{Statistics@Statistics!fit curve to data@fit curve to data}make a
choice in the dialog box.

\begin{itemize}
\item  For straight-line fits, choose \textsf{Multiple Regression} or 
\textsf{Multiple Regression (no constant).}

\item  For best fits by polynomials, choose \textsf{Polynomial of Degree
\lbrack\ \rbrack }.\medskip 
\end{itemize}

\subsection{\ Linear Regression\label{Multiple regression}}

\textsf{Multiple Regression} calculates 
\index{Statistics@Statistics!regression@regression}\label%
{Statistics, regression}linear-regression 
\index{Regression@Regression}\label{Regression}equations with 
\index{Multiple regression@Multiple regression}\textsl{keyed} or labeled
data matrices. The result is an equation expressing the variable at the head
of the first column as a linear combination of the variables heading the
remaining columns, plus a constant (that is missing if \textsf{Multiple
Regression (no constant)} was chosen). The equation produced is the best fit
to the data in the least-squares sense.

\begin{quote}
$\blacktriangleright $ \textsf{Statistics + Fit Curve to Data + Multiple
Regression}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
y & x \\ 
0\;\; & 1.1 \\ 
0.5 & 1.5 \\ 
1\;\; & 1.9 \\ 
1.5 & 2.4 \\ 
2\;\; & 2.9
\end{array}
\right] $, Regression is: $y=-1.1703+1.1073x$\medskip

$\left( 
\begin{array}{cc}
x & y \\ 
a & b \\ 
c & d
\end{array}
\right) $, Regression is: $x=%
\dfrac{ad-bc}{d-b}-\dfrac{a-c}{d-b}y\,$
\end{quotation}

\begin{quote}
$\blacktriangleright $ \textsf{Statistics + Fit Curve to Data + Multiple
Regression}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{ccc}
z & x & y \\ 
1 & 0\;\; & 1.1 \\ 
2 & 0.5 & 1.1 \\ 
4 & 1\;\; & 1.9 \\ 
5 & 1.5 & 1.9 \\ 
7 & 2\;\; & 2.9
\end{array}
\right] $, Regression is: $z=-.126+2.09x+\allowbreak 1.03y$
\end{quotation}

The choice \textsf{Multiple Regression (no constant)} gives the following
linear equations.

\begin{quote}
$\blacktriangleright $ \textsf{Statistics + Fit Curve to Data + Multiple
Regression (no constant)}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
u & v \\ 
0\;\; & 1.1 \\ 
0.5 & 1.5 \\ 
1\;\; & 1.9 \\ 
1.5 & 2.4 \\ 
2\;\; & 2.9
\end{array}
\right] $, Regression is: $u=.56733v\medskip $

$\left[ 
\begin{array}{ccc}
z & x & y \\ 
1 & 0\;\; & 1.1 \\ 
2 & 0.5 & 1.1 \\ 
4 & 1\;\; & 1.9 \\ 
5 & 1.5 & 1.9 \\ 
7 & 2\;\; & 2.9
\end{array}
\right] $, Regression is: $z=2.1829x+.91245y\medskip $

$\left( 
\begin{array}{cc}
x & y \\ 
a & b \\ 
c & d
\end{array}
\right) $, Regression is: $x=\dfrac{ba+dc}{b^{2}+d^{2}}y$
\end{quotation}

\strut

\subsection{\ \label{Statistics, polynomial fit to data}Polynomial Fit}

\textsf{Polynomial of Degree [ ]} calculates polynomial equations from
labeled or unlabeled two-column data matrices. The result is a polynomial of
the specified degree that is the best fit to the data in the least-squares
sense. For the polynomial fit, the $x$ column appears first.

To find the best fit by a polynomial of second 
\index{Statistics@Statistics!polynomial fit to data@polynomial fit to data}
degree to the set of points 
\[
\left( 0,.64\right) ,\left( .5,.09\right) ,\left( 1,.04\right) ,\left(
1.5,.49\right) ,\left( 2,1.44\right) 
\]
first remove the parentheses and convert the entries into a two-column
matrix. To make this conversion, place the insertion point in the list; from
the \textsf{Matrices }submenu, choose \textsf{Reshape}; then specify two
columns.

\begin{quote}
$\blacktriangleright $ \textsf{Matrices + Reshape}
\end{quote}

\begin{quotation}
$0,.64,.5,.09,1,.04,1.5,.49,2,1.44$, $\left[ 
\begin{array}{cc}
0 & 0.64 \\ 
0.5 & 0.09 \\ 
1 & 0.04 \\ 
1.5 & 0.49 \\ 
2 & 1.44
\end{array}
\right] $
\end{quotation}

To find the parabola that best fits the data, make the following choices.

\begin{quote}
$\blacktriangleright $ \textsf{Statistics + Fit Curve to Data}

Select\textsf{\ Polynomial of Degree [} ], enter \QTR{UserInput}{2}, click 
\textsf{OK}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
0 & 0.64 \\ 
0.5 & 0.09 \\ 
1.0 & 0.04 \\ 
1.5 & 0.49 \\ 
2.0 & 1.44
\end{array}
\right] $, Polynomial fit: $y=.64-1.6x+\allowbreak 1.0x^{2}\,\medskip $

$\left[ 
\begin{array}{rr}
x & y \\ 
0 & 6 \\ 
1 & .1 \\ 
2 & -3 \\ 
3 & 2 \\ 
4 & 8
\end{array}
\right] $, Polynomial fit: $y=5.9971-8.5243x+\allowbreak 2.2786x^{2}$
\end{quotation}

You can plot the points and polynomial on the same graph. You will notice
that these points were chosen such that they lie on the parabola.

\begin{quote}
$\blacktriangleright $ \textsf{Plot 2D + Rectangular}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
0 & 0.64 \\ 
0.5 & 0.09 \\ 
1.0 & 0.04 \\ 
1.5 & 0.49 \\ 
2.0 & 1.44
\end{array}
\right] ,.64-1.6x+\allowbreak 1.0x^{2}$
\end{quotation}

\FRAME{dtbpF}{2.9992in}{1.9995in}{0pt}{}{}{Plot }{\special{language
"Scientific Word";type "MAPLEPLOT";width 2.9992in;height 1.9995in;depth
0pt;display "PICT";function \TEXUX{$\left[
\MATRIX{2,5}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,,,,}\CELL{0}\CELL{0.64}%
\CELL{0.5}\CELL{0.09}\CELL{1.0}\CELL{0.04}\CELL{1.5}\CELL{0.49}\CELL{2.0}%
\CELL{1.44}\right] $};linecolor "black";linestyle 1;linethickness
1;pointstyle "point";function \TEXUX{$.64-1.6x+\allowbreak
1.0x^{2}$};linecolor "red";linestyle 1;linethickness 1;pointstyle
"point";function \TEXUX{$\left[
\MATRIX{2,5}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,,,,}\CELL{0}\CELL{0.64}%
\CELL{0.5}\CELL{0.09}\CELL{1.0}\CELL{0.04}\CELL{1.5}\CELL{0.49}\CELL{2.0}%
\CELL{1.44}\right] $};linecolor "black";linestyle 1;linethickness
1;pointstyle "circle";pointplot TRUE;xmin "-0.047584";xmax
"1.768007";xviewmin "-0.047584";xviewmax "1.768007";yviewmin
"-0.0285";yviewmax "1.0";viewset"XY";rangeset"X";phi 45;theta 45;plottype
4;numpoints 49;axesstyle "normal";xis \TEXUX{x};var1name \TEXUX{$x$};}}

\begin{quote}
$\blacktriangleright $ \textsf{Plot 2D + Rectangular}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{rr}
0 & 6 \\ 
1 & .1 \\ 
2 & -3 \\ 
3 & 2 \\ 
4 & 8
\end{array}
\right] ,5.9971-8.5243x+\allowbreak 2.2786x^{2}$
\end{quotation}

\FRAME{dtbpF}{3in}{2.0003in}{0pt}{}{}{}{\special{language "Scientific
Word";type "MAPLEPLOT";width 3in;height 2.0003in;depth 0pt;display
"PICT";function \TEXUX{$5.9971-8.5243x+\allowbreak 2.2786x^{2}$};linecolor
"blue";linestyle 1;linethickness 1;pointstyle "point";function
\TEXUX{$\left[
\MATRIX{2,5}{c}\VR{,,r,,,}{,,r,,,}{,,,,,}\HR{,,,,,}\CELL{0}\CELL{6}\CELL{1}%
\CELL{.1}\CELL{2}\CELL{-3}\CELL{3}\CELL{2}\CELL{4}\CELL{8}\right]
$};linecolor "red";linestyle 1;linethickness 1;pointstyle "point";xmin
"0";xmax "4";xviewmin "0";xviewmax "4";yviewmin "-3.227";yviewmax
"8.589";rangeset"X";phi 45;theta 45;plottype 4;numpoints 49;axesstyle
"normal";xis \TEXUX{x};var1name \TEXUX{$x$};}}

You can also fit data with polynomials of higher degree.

\begin{quote}
$\blacktriangleright $ \textsf{Statistics + Fit Curve to Data}

Select\textsf{\ Polynomial of Degree [ ]}, enter \QTR{UserInput}{3}, click 
\textsf{OK}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
0 & 0.64 \\ 
0.5 & 0.09 \\ 
1.0 & 8.04 \\ 
1.5 & 0.49 \\ 
2.0 & -7.44
\end{array}
\right] $, Polynomial fit: $y=8.1143\times 10^{-2}+1.4114x+\allowbreak
9.1143x^{2}-5.92x^{3}$
\end{quotation}

\FRAME{dtbpF}{2.9992in}{1.9995in}{0pt}{}{}{Plot }{\special{language
"Scientific Word";type "MAPLEPLOT";width 2.9992in;height 1.9995in;depth
0pt;display "PICT";function \TEXUX{$\left[
\MATRIX{2,5}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,,,,}\CELL{0}\CELL{0.64}%
\CELL{0.5}\CELL{0.09}\CELL{1.0}\CELL{8.04}\CELL{1.5}\CELL{0.49}\CELL{2.0}%
\CELL{-7.44}\right] $};linecolor "black";linestyle 1;linethickness
1;pointstyle "circle";function \TEXUX{$8.1143\times
10^{-2}+1.4114x+\allowbreak 9.1143x^{2}-5.92x^{3}$};linecolor
"red";linestyle 1;linethickness 1;pointstyle "point";function
\TEXUX{$\MATRIX{2,5}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,,,,}\CELL{0}%
\CELL{0.64}\CELL{0.5}\CELL{0.09}\CELL{1.0}\CELL{8.04}\CELL{1.5}\CELL{0.49}%
\CELL{2.0}\CELL{-7.44}$};linecolor "black";linestyle 1;linethickness
1;pointstyle "circle";pointplot TRUE;function \TEXUX{$\left[
\MATRIX{2,5}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,,,,}\CELL{0}\CELL{0.64}%
\CELL{0.5}\CELL{0.09}\CELL{1.0}\CELL{8.04}\CELL{1.5}\CELL{0.49}\CELL{2.0}%
\CELL{-7.44}\right] $};linecolor "black";linestyle 1;linethickness
1;pointstyle "point";xmin "-0.440109";xmax "2.141344";xviewmin
"-0.440109";xviewmax "2.141344";yviewmin "-12";yviewmax
"8.474";viewset"XY";rangeset"X";phi 45;theta 45;plottype 4;numpoints
49;axesstyle "normal";xis \TEXUX{x};var1name \TEXUX{$x$};}}

\begin{quote}
$\blacktriangleright $ \textsf{Statistics + Fit Curve to Data,}

Select\textsf{\ Polynomial of Degree [ ]}, enter \QTR{UserInput}{4}, click 
\textsf{OK}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
1 & 12 \\ 
3 & 4 \\ 
5 & 6 \\ 
7 & 8 \\ 
9 & 18
\end{array}
\right] $, Polynomial fit: $y=\frac{1779}{64}-\frac{529}{24}x+\frac{229}{32}%
x^{2}-\frac{23}{24}x^{3}+\frac{3}{64}x^{4}$
\end{quotation}

\FRAME{dtbpF}{3in}{2.0003in}{0pt}{}{}{}{\special{language "Scientific
Word";type "MAPLEPLOT";width 3in;height 2.0003in;depth 0pt;display
"PICT";plot-snapshots TRUE;function
\TEXUX{$\frac{1779}{64}-\frac{529}{24}x+\frac{229}{32}x^{2}-%
\frac{23}{24}x^{3}+\frac{3}{64}x^{4}$};linecolor "blue";linestyle
1;linethickness 1;pointstyle "point";function \TEXUX{$\left[
\MATRIX{2,5}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,,,,}\CELL{1}\CELL{12}\CELL{3}%
\CELL{4}\CELL{5}\CELL{6}\CELL{7}\CELL{8}\CELL{9}\CELL{18}\right]
$};linecolor "red";linestyle 1;linethickness 1;pointstyle "point";xmin
"1";xmax "9";xviewmin "-1";xviewmax "10";yviewmin "3.72";yviewmax
"18.29";viewset"XY";rangeset"X";phi 45;theta 45;plottype 4;numpoints
49;axesstyle "normal";xis \TEXUX{x};var1name \TEXUX{$x$};}}

\ 

\subsection{\ \label{Overdetermined systems}Overdetermined Systems of
Equations}

The \textsf{Solve} command has been 
\index{Overdetermined systems@Overdetermined systems}extended to handle
overdetermined systems, returning the least-squares solution 
\index{Least-squares solution@Least-squares solution}. Here we give an
example of an overdetermined system. Note that (as before) the least-squares
solution is the \emph{actual} solution, when an actual solution exists.\ 

\begin{quote}
$\blacktriangleright $ \textsf{Solve + Exact}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
1 & 2 \\ 
3 & 4 \\ 
5 & 6 \\ 
7 & 8
\end{array}
\right] \left[ 
\begin{array}{c}
x \\ 
y
\end{array}
\right] =\left[ 
\begin{array}{r}
3 \\ 
7 \\ 
11 \\ 
15
\end{array}
\right] $, Solution is : $\left[ 
\begin{array}{c}
1 \\ 
1
\end{array}
\right] $
\end{quotation}

It is easy to multiply both sides of a matrix equation by $A^T$ to check
that, when you ``solve'' $AX=B$, you are actually getting the solution of $%
\left( A^TA\right) X=A^TB$.

\begin{quotation}
$\left( A^{T}A\right) X=\left( \left[ 
\begin{array}{cccc}
1 & 3 & 5 & 7 \\ 
2 & 4 & 6 & 8
\end{array}
\right] \left[ 
\begin{array}{cc}
1 & 2 \\ 
3 & 4 \\ 
5 & 6 \\ 
7 & 8
\end{array}
\right] \right) \left[ 
\begin{array}{c}
x \\ 
y
\end{array}
\right] \medskip $

$\qquad \qquad =\left( \left[ 
\begin{array}{cc}
84 & 100 \\ 
100 & 120
\end{array}
\right] \right) \left[ 
\begin{array}{c}
x \\ 
y
\end{array}
\right] \bigskip $

$A^{T}B=\left[ 
\begin{array}{cccc}
1 & 3 & 5 & 7 \\ 
2 & 4 & 6 & 8
\end{array}
\right] \left[ 
\begin{array}{c}
3 \\ 
7 \\ 
11 \\ 
15
\end{array}
\right] =\left[ 
\begin{array}{c}
184 \\ 
220
\end{array}
\right] $
\end{quotation}

This calculation gives the following equation, which has an exact solution.

\begin{quote}
$\blacktriangleright $ \textsf{Evaluate}
\end{quote}

\begin{quotation}
$\left[ 
\begin{array}{cc}
84 & 100 \\ 
100 & 120
\end{array}
\right] \left[ 
\begin{array}{c}
1 \\ 
1
\end{array}
\right] =\left[ 
\begin{array}{c}
184 \\ 
220
\end{array}
\right] $
\end{quotation}

\strut

\subsection{\ Related topics}

\begin{itemize}
\item  
\hyperref{Menu Items, Lists, and Matrices}{}{}{DM11-1.tex#Statistics}

\item  \hyperref{Measures of Central Tendency}{}{}{DM11-2.tex#Statistics,
mean}

\item  \hyperref{Measures of Dispersion}{}{}{DM11-3.tex#Mean deviation}

\item  \hyperref{Distributions and Densities}{}{}{DM11-4.tex#Distribution}

\item  \hyperref{Families of Continuous Distributions}{}{}{%
DM11-5.tex#Continuous distributions}

\item  \hyperref{Families of Discrete Distributions}{}{}{DM11-6.tex#Discrete
distributions}

\item  \hyperref{Random Numbers}{}{}{DM11-7.tex#Statistics, random numbers}

\item  \hyperref{Exercises and Solutions}{}{}{DM11-9.tex#Exercises}
\end{itemize}

\rule{0.67in}{0.01in}

\hyperref{\FRAME{itbpF}{0.5275in}{0.3399in}{0.0519in}{}{}{index.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";display "PICT";valid-file
"F";width 0.5275in;height 0.3399in;depth 0.0519in;original-width
36.125pt;original-height 22.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'index.wmf';file-properties "XNPEU";}}}{}{}{%
DMIndex.tex#Math Index}\quad {\small Index entries: \hyperref{Data}{}{}{%
DMIndex.tex#Data}, \hyperref{Matrices}{}{}{DMIndex.tex#Matrices}, \hyperref{%
Reshape}{}{}{DMIndex.tex#Reshape}, }\hyperref{Solve}{}{}{DMIndex.tex#Solve}, 
{\small \hyperref{Statistics}{}{}{DMIndex.tex#Statistics}}

\end{document}
