Moved least square fitting to session 4; removed vander function.
authorPuneeth Chaganti <punchagan@fossee.in>
Wed, 04 Nov 2009 22:08:13 +0530
changeset 268 f978ddc90960
parent 267 978d06520462
child 269 9c9be698d7ad
Moved least square fitting to session 4; removed vander function.
day1/session3.tex
day1/session4.tex
--- a/day1/session3.tex	Wed Nov 04 10:35:53 2009 +0530
+++ b/day1/session3.tex	Wed Nov 04 22:08:13 2009 +0530
@@ -527,116 +527,4 @@
 \end{lstlisting}
 \end{frame}
 
-\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}
-
-%%making vander without vander, simple matrix
-\subsection{Van der Monde matrix generation}
-\begin{frame}[fragile]
-\frametitle{Van der Monde Matrix}
-\begin{itemize}
-\item A is also called a Van der Monde matrix
-\item It can be generated using \typ{vander}
-\end{itemize}
-\begin{lstlisting}
-In []: A = vander(L, 2)
-\end{lstlisting}
-Gives the required Van der Monde matrix
-\begin{equation*}
-  \begin{bmatrix}
-    l_1 & 1 \\
-    l_2 & 1 \\
-    \vdots & \vdots\\
-    l_N & 1 \\
-  \end{bmatrix}
-\end{equation*}
-
-\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}
-
-\begin{frame}[fragile]
-  \frametitle{What did we learn?}
-  \begin{itemize}
-   \item Least square fit
-   \item Van der Monde matrix generation
-   \item Plotting the least square fit curve
-  \end{itemize}
-\end{frame}
-
 \end{document}
--- 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}