--- a/day1/session4.tex Fri Mar 05 23:59:12 2010 +0530
+++ b/day1/session4.tex Mon Mar 08 20:45:33 2010 +0530
@@ -164,7 +164,7 @@
array([[ 1., 0.],
[ 0., 1.]])
\end{lstlisting}
-Also available \alert{\typ{zeros, zeros_like, empty, empty_like}}
+Also available \alert{\typ{zeros, zeros_like}}
\end{small}
\end{frame}
@@ -182,8 +182,6 @@
Out[]: 23
In []: c[1,2]
Out[]: 23
-In []: c[1]
-Out[]: array([21, 22, 23])
\end{lstlisting}
\end{frame}
@@ -191,6 +189,9 @@
\frametitle{Changing elements}
\begin{small}
\begin{lstlisting}
+In []: c[1]
+Out[]: array([21, 22, 23])
+
In []: c[1,1] = -22
In []: c
Out[]:
@@ -206,7 +207,7 @@
[31, 32, 33]])
\end{lstlisting}
\end{small}
-How to change one \alert{column}?
+How to access one \alert{column}?
\end{frame}
\begin{frame}[fragile]
@@ -294,23 +295,28 @@
\end{frame}
\begin{frame}[fragile]
- \frametitle{Slicing \& Striding Exercises}
+ \frametitle{Elementary image processing}
\begin{small}
\begin{lstlisting}
In []: a = imread('lena.png')
In []: imshow(a)
Out[]: <matplotlib.image.AxesImage object at 0xa0384cc>
+ \end{lstlisting}
+ \end{small}
+\typ{imread} returns an array of shape (512, 512, 4) which represents an image of 512x512 pixels and 4 shades.\\
+\typ{imshow} renders the array as an image.
+\end{frame}
- \end{lstlisting}
-\end{small}
+\begin{frame}[fragile]
+\frametitle{Slicing \& Striding Exercises}
\begin{itemize}
\item Crop the image to get the top-left quarter
\item Crop the image to get only the face
\item Resize image to half by dropping alternate pixels
\end{itemize}
+
\end{frame}
-
\begin{frame}[fragile]
\frametitle{Solutions}
\begin{small}
@@ -345,14 +351,6 @@
\end{frame}
\begin{frame}[fragile]
- \frametitle{Sum of all elements}
- \begin{lstlisting}
-In []: sum(a)
-Out[]: 12
- \end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
\frametitle{Matrix Addition}
\begin{lstlisting}
In []: b = array([[3,2,-1,5],
@@ -410,11 +408,16 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Determinant}
+\frametitle{Determinant and sum of all elements}
\begin{lstlisting}
In []: det(a)
Out[]: 80.0
\end{lstlisting}
+ \begin{lstlisting}
+In []: sum(a)
+Out[]: 12
+ \end{lstlisting}
+
\end{frame}
%%use S=array(X,Y)
@@ -467,7 +470,8 @@
\section{Least Squares Fit}
\begin{frame}[fragile]
\frametitle{$L$ vs. $T^2$ - Scatter}
-\vspace{-0.15in}
+Linear trend visible.
+\vspace{-0.1in}
\begin{figure}
\includegraphics[width=4in]{data/L-Tsq-points}
\end{figure}
@@ -475,37 +479,24 @@
\begin{frame}[fragile]
\frametitle{$L$ vs. $T^2$ - Line}
-\vspace{-0.15in}
+This line does not make any mathematical sense.
+\vspace{-0.1in}
\begin{figure}
\includegraphics[width=4in]{data/L-Tsq-Line}
\end{figure}
\end{frame}
\begin{frame}[fragile]
-\frametitle{$L$ vs. $T^2$ }
\frametitle{$L$ vs. $T^2$ - Least Square Fit}
-\vspace{-0.15in}
+This is what our intention is.
+\vspace{-0.1in}
\begin{figure}
\includegraphics[width=4in]{data/least-sq-fit}
\end{figure}
\end{frame}
-\begin{frame}
-\frametitle{Least Square Fit Curve}
-\begin{center}
-\begin{itemize}
-\item $L \alpha T^2$
-\item Best Fit Curve $\rightarrow$ Linear
- \begin{itemize}
- \item Least Square Fit
- \end{itemize}
-\item \typ{lstsq()}
-\end{itemize}
-\end{center}
-\end{frame}
-
\begin{frame}[fragile]
-\frametitle{\typ{lstsq}}
+\frametitle{Matrix Formulation}
\begin{itemize}
\item We need to fit a line through points for the equation $T^2 = m \cdot L+c$
\item In matrix form, the equation can be represented as $T_{sq} = A \cdot p$, where $T_{sq}$ is
@@ -535,11 +526,11 @@
\frametitle{Getting $L$ and $T^2$}
%If you \alert{closed} IPython after session 2
\begin{lstlisting}
-In []: l = []
+In []: L = []
In []: t = []
In []: for line in open('pendulum.txt'):
.... point = line.split()
- .... l.append(float(point[0]))
+ .... L.append(float(point[0]))
.... t.append(float(point[1]))
....
....
@@ -549,7 +540,7 @@
\begin{frame}[fragile]
\frametitle{Getting $L$ and $T^2$ \dots}
\begin{lstlisting}
-In []: l = array(l)
+In []: L = array(L)
In []: t = array(t)
\end{lstlisting}
\alert{\typ{In []: tsq = t*t}}
@@ -558,7 +549,7 @@
\begin{frame}[fragile]
\frametitle{Generating $A$}
\begin{lstlisting}
-In []: A = array([l, ones_like(l)])
+In []: A = array([L, ones_like(L)])
In []: A = A.T
\end{lstlisting}
%% \begin{itemize}
@@ -586,13 +577,15 @@
\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]
+In []: Tline = coef[0]*L + coef[1]
+
+In []: Tline.shape
\end{lstlisting}
\begin{itemize}
-\item Now plot \typ{Tline} vs. \typ{l}, to get the Least squares fit line.
+\item Now plot \typ{Tline} vs. \typ{L}, to get the Least squares fit line.
\end{itemize}
\begin{lstlisting}
-In []: plot(l, Tline)
+In []: plot(L, Tline)
\end{lstlisting}
\end{frame}