--- a/day1/session4.tex Wed Nov 04 10:35:53 2009 +0530
+++ b/day1/session4.tex Wed Nov 04 22:08:13 2009 +0530
@@ -306,6 +306,102 @@
\inctime{15}
\end{frame}
+\section{Least Squares Fit}
+\begin{frame}[fragile]
+\frametitle{Least Squares Fit}
+\vspace{-0.15in}
+\begin{figure}
+\includegraphics[width=4in]{data/L-Tsq-Line.png}
+\end{figure}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Least Squares Fit}
+\vspace{-0.15in}
+\begin{figure}
+\includegraphics[width=4in]{data/L-Tsq-points.png}
+\end{figure}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Least Squares Fit}
+\vspace{-0.15in}
+\begin{figure}
+\includegraphics[width=4in]{data/least-sq-fit.png}
+\end{figure}
+\end{frame}
+
+\begin{frame}
+\frametitle{Least Square Fit Curve}
+\begin{itemize}
+\item $T^2$ and $L$ have a linear relationship
+\item Hence, Least Square Fit Curve is a line
+\item we shall use the \typ{lstsq} function
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\typ{lstsq}}
+\begin{itemize}
+\item We need to fit a line through points for the equation $T^2 = m \cdot L+c$
+\item The equation can be re-written as $T^2 = A \cdot p$
+\item where A is
+ $\begin{bmatrix}
+ L_1 & 1 \\
+ L_2 & 1 \\
+ \vdots & \vdots\\
+ L_N & 1 \\
+ \end{bmatrix}$
+ and p is
+ $\begin{bmatrix}
+ m\\
+ c\\
+ \end{bmatrix}$
+\item We need to find $p$ to plot the line
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Generating $A$}
+\begin{lstlisting}
+In []: A = array([L, ones_like(L)])
+In []: A = A.T
+\end{lstlisting}
+%% \begin{itemize}
+%% \item A is also called a Van der Monde matrix
+%% \item It can also be generated using \typ{vander}
+%% \end{itemize}
+%% \begin{lstlisting}
+%% In []: A = vander(L, 2)
+%% \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\typ{lstsq} \ldots}
+\begin{itemize}
+\item Now use the \typ{lstsq} function
+\item Along with a lot of things, it returns the least squares solution
+\end{itemize}
+\begin{lstlisting}
+In []: coef, res, r, s = lstsq(A,TSq)
+\end{lstlisting}
+\end{frame}
+
+\subsection{Plotting}
+\begin{frame}[fragile]
+\frametitle{Least Square Fit Line \ldots}
+We get the points of the line from \typ{coef}
+\begin{lstlisting}
+In []: Tline = coef[0]*L + coef[1]
+\end{lstlisting}
+\begin{itemize}
+\item Now plot Tline vs. L, to get the Least squares fit line.
+\end{itemize}
+\begin{lstlisting}
+In []: plot(L, Tline)
+\end{lstlisting}
+\end{frame}
+
\section{Solving linear equations}
\begin{frame}[fragile]
@@ -476,6 +572,7 @@
\item Norms
\item Singular Value Decomposition
\end{itemize}
+ \item Least Square Curve fitting
\item Solving linear equations
\end{itemize}
\end{frame}