day2/session1.tex
changeset 9 2281002b579b
parent 6 1f9492506ba2
child 10 84c3f600045f
equal deleted inserted replaced
6:1f9492506ba2 9:2281002b579b
   168   \item arbitrary dimensionality
   168   \item arbitrary dimensionality
   169   \item \typ{arr.shape}: size in each dimension
   169   \item \typ{arr.shape}: size in each dimension
   170   \item \alert{Note:} \typ{len(arr) != arr.size} in general
   170   \item \alert{Note:} \typ{len(arr) != arr.size} in general
   171   \item \alert{Note:} By default array operations are performed
   171   \item \alert{Note:} By default array operations are performed
   172     \alert{elementwise}
   172     \alert{elementwise}
   173   \item Indices, slicing: just like lists 
       
   174   \end{itemize}
   173   \end{itemize}
   175 \end{frame}
   174 \end{frame}
   176 
   175 
   177 
   176 
   178 \begin{frame}[fragile]
   177 \begin{frame}[fragile]
   190 1 8
   189 1 8
   191 >>> x[0] = 10
   190 >>> x[0] = 10
   192 >>> print x[0], x[-1]
   191 >>> print x[0], x[-1]
   193 10.0 4.0
   192 10.0 4.0
   194 \end{lstlisting}
   193 \end{lstlisting}
   195     
       
   196 \inctime{10}
       
   197 \end{frame}
   194 \end{frame}
   198 
   195 
   199 \begin{frame}[fragile]
   196 \begin{frame}[fragile]
   200   \frametitle{Multi-dimensional arrays}
   197   \frametitle{Multi-dimensional arrays}
   201 \begin{lstlisting}
   198 \begin{lstlisting}
   221       a)} etc.
   218       a)} etc.
   222   \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)},
   219   \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)},
   223     \typ{less (<)}, \typ{greater (>)} etc.
   220     \typ{less (<)}, \typ{greater (>)} etc.
   224   \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x),
   221   \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x),
   225       exp(x), sqrt(x)} etc.
   222       exp(x), sqrt(x)} etc.
   226   \item \typ{sum(x, axis=0), product(x, axis=0)} 
   223   \item \typ{sum(x, axis=0), product(x, axis=0), dot(a, bp)}   \inctime{10}
   227   \item \typ{dot(a, bp)}
       
   228   \end{itemize}
   224   \end{itemize}
   229   \inctime{10}
   225 
   230 \end{frame}
   226 \end{frame}
   231 
   227 
   232 \subsection{Array Creation \& Slicing, Striding Arrays}
   228 \subsection{Array Creation \& Slicing, Striding Arrays}
   233 \begin{frame}[fragile]
   229 \begin{frame}[fragile]
   234   \frametitle{Array creation functions}
   230   \frametitle{Array creation functions}
   255 >>> a[1:,1:]
   251 >>> a[1:,1:]
   256 array([[5, 6],
   252 array([[5, 6],
   257        [8, 9]])
   253        [8, 9]])
   258 >>> a[:,2]
   254 >>> a[:,2]
   259 array([3, 6, 9])
   255 array([3, 6, 9])
       
   256 >>> a[...,2]
       
   257 array([3, 6, 9])
   260 \end{lstlisting}
   258 \end{lstlisting}
   261 \end{frame}
   259 \end{frame}
   262 
   260 
   263 \begin{frame}[fragile]
   261 \begin{frame}[fragile]
   264   \frametitle{Striding arrays}
   262   \frametitle{Striding arrays}
   291     >>> A=misc.imread(name)
   289     >>> A=misc.imread(name)
   292     >>> misc.imshow(A)
   290     >>> misc.imshow(A)
   293   \end{lstlisting}
   291   \end{lstlisting}
   294     \begin{enumerate}
   292     \begin{enumerate}
   295     \item Convert an RGB image to Grayscale. $ Y = 0.5R + 0.25G + 0.25B $
   293     \item Convert an RGB image to Grayscale. $ Y = 0.5R + 0.25G + 0.25B $
       
   294     \item Scale the image to 50\%
       
   295     \item Introduce some random noise?
   296     \end{enumerate}
   296     \end{enumerate}
   297 \inctime{15}
   297 \inctime{15}
   298 \end{frame}
   298 \end{frame}
   299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   300 
   300 
   721 
   721 
   722   \inctime{25}
   722   \inctime{25}
   723 \end{frame}
   723 \end{frame}
   724 
   724 
   725 \begin{frame}
   725 \begin{frame}
   726   \frametitle{Problem set 1.0}
   726   \frametitle{Problem Set}
   727   \begin{enumerate}
   727   \begin{enumerate}
   728       \item Write a function that plots any n-gon given \typ{n}.
   728       \item Write a function that plots any n-gon given \typ{n}.
   729       \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for
   729       \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for
   730           $k=2.5, 3.5$ and $4$
   730           $k=2.5, 3.5$ and $4$
   731 \end{enumerate}
   731 \end{enumerate}
   732 \end{frame}
   732 \end{frame}
   733 
   733 
   734 \begin{frame}
   734 \begin{frame}[fragile] 
   735   \frametitle{Problem set 1.1}
   735 \frametitle{Problem Set}
   736   \begin{enumerate}
   736   \begin{columns}
       
   737     \column{0.6\textwidth}
       
   738     \small{
       
   739     \begin{enumerate}
   737       \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) =
   740       \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) =
   738           kx(1-x)$.  Plot the successive iterates of this process.
   741           kx(1-x)$.  Plot the successive iterates of this process.
   739       \item Plot this using a cobweb plot as follows:
   742       \item Plot this using a cobweb plot as follows:
   740           \begin{enumerate}
   743           \begin{enumerate}
   741               \item Start at $(x_0, 0)$
   744               \item Start at $(x_0, 0)$
   742               \item Draw line to $(x_i, f(x_i))$; 
   745               \item Draw line to $(x_i, f(x_i))$; 
   743               \item Set $x_{i+1} = f(x_i)$
   746               \item Set $x_{i+1} = f(x_i)$
   744               \item Draw line to $(x_i, x_i)$
   747               \item Draw line to $(x_i, x_i)$
   745               \item Repeat from 2 for as long as you want 
   748               \item Repeat from 2 for as long as you want 
   746           \end{enumerate}
   749           \end{enumerate}
   747     \end{enumerate}
   750     \end{enumerate}}
   748 \end{frame}
   751     \column{0.35\textwidth}
   749 
   752     \hspace*{-0.5in}
   750 \begin{frame}
   753   \includegraphics[height=1.6in, interpolate=true]{data/cobweb}  
   751   \frametitle{Problem set 1.2}
   754 \end{columns}
   752   \begin{enumerate}
   755 \inctime{20}
   753 
   756 \end{frame}
   754       \item Plot the Koch snowflake.  Write a function to generate the
   757 
   755           necessary points given the two points constituting a line.
       
   756           \pause
       
   757           \begin{enumerate}
       
   758               \item Split the line into 4 segments.
       
   759               \item The first and last segments are trivial.
       
   760               \item To rotate the point you can use complex numbers,
       
   761                   recall that $z e^{j \theta}$ rotates a point $z$ in 2D
       
   762                   by $\theta$.
       
   763               \item Do this for all line segments till everything is
       
   764                   done.
       
   765           \end{enumerate}
       
   766       \item Show rate of convergence for a first and second order finite
       
   767           difference of sin(x)
       
   768 \end{enumerate}
       
   769 \inctime{30}
       
   770 \end{frame}
       
   771 \end{document}
   758 \end{document}