# HG changeset patch # User Puneeth Chaganti # Date 1255142030 -19800 # Node ID a749db24e73b997c406749c2ffc69a039cede8e0 # Parent 691608044ae7d8b533ad057c0fd974f69490aecd Added Dialogs Slide; More edits to Day2 slides. diff -r 691608044ae7 -r a749db24e73b day2/session1.tex --- a/day2/session1.tex Fri Oct 09 17:14:00 2009 +0530 +++ b/day2/session1.tex Sat Oct 10 08:03:50 2009 +0530 @@ -237,14 +237,14 @@ \begin{frame}[fragile] \frametitle{Array math cont.} \begin{itemize} - \item Logical operations: \typ{np.equal (==)}, \typ{np.not\_equal (!=)}, - \typ{np.less (<)}, \typ{np.greater (>)} etc. + \item Logical operations: \typ{==}, \typ{!=}, + \typ{<}, \typ{>} etc. \item Trig and other functions: \typ{np.sin(x),} \typ{np.arcsin(x), np.sinh(x),} \typ{np.exp(x), np.sqrt(x)} etc. \end{itemize} \begin{lstlisting} ->>> np.greater(a,4) +>>> a<4, a!=3 >>> np.sqrt(a) \end{lstlisting} \inctime{10} @@ -260,7 +260,7 @@ >>> np.array([2,3,4]) array([2, 3, 4]) \end{lstlisting} - \item \typ{np.linspace(start,stop,...)} + \item \typ{np.linspace(start,stop,num)} \begin{lstlisting} >>> np.linspace(0, 2, 4) array([0.,0.6666667,1.3333333,2.]) @@ -274,7 +274,7 @@ \begin{itemize} \item \typ{np.ones(shape, dtype=None, ...)} \begin{lstlisting} ->>>np.ones([2,2]) +>>>np.ones((2,2)) array([[ 1., 1.], [ 1., 1.]]) \end{lstlisting} @@ -376,10 +376,10 @@ # LaTeX markup! >>> ylabel(r'sin($\chi$)', color='r') >>> title('Simple figure', fontsize=20) ->>> savefig('/tmp/test.eps') +>>> savefig('/tmp/test.png') \end{lstlisting} \begin{itemize} - \item Also: PNG, PDF, PS, EPS, SVG, PDF + \item Also: PDF, PS, EPS, SVG, PDF \end{itemize} \inctime{5} \end{frame} @@ -786,13 +786,12 @@ \column{0.6\textwidth} \small{ \begin{enumerate} - \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) = - kx(1-x)$. Plot the successive iterates of this process. + \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) = kx(1-x)$. Plot the successive iterates of this process. \item Plot this using a cobweb plot as follows: \begin{enumerate} \item Start at $(x_0, 0)$ \item Draw line to $(x_i, f(x_i))$; - \item Set $x_{i+1} = f(x_i)$ + \item Set $x_i = f(x_i)$ \item Draw line to $(x_i, x_i)$ \item Repeat from 2 for as long as you want \end{enumerate} diff -r 691608044ae7 -r a749db24e73b day2/session2.tex --- a/day2/session2.tex Fri Oct 09 17:14:00 2009 +0530 +++ b/day2/session2.tex Sat Oct 10 08:03:50 2009 +0530 @@ -120,7 +120,6 @@ \section{Advanced Numpy} \begin{frame}[fragile] \frametitle{Broadcasting} - Try it! \begin{lstlisting} >>> a = np.arange(4) >>> b = np.arange(5) @@ -176,7 +175,6 @@ \begin{frame}[fragile] \frametitle{Copies \& Views} - Try it! \vspace{-0.1in} \begin{lstlisting} >>> a = np.arange(1,9); a.shape=3,3 @@ -195,7 +193,6 @@ \begin{frame}[fragile] \frametitle{Copies \& Views} - Try it! \vspace{-0.1in} \begin{lstlisting} >>> b = a[0,1:3] @@ -274,12 +271,11 @@ \subsection{Linear Algebra} \begin{frame}[fragile] \frametitle{Linear Algebra} - Try it! \begin{lstlisting} >>> import scipy as sp >>> from scipy import linalg - >>> A=sp.mat(np.arange(1,10)) - >>> A.shape=3,3 + >>> A = sp.array(sp.arange(1,10)) + >>> A.shape = 3,3 >>> linalg.inv(A) >>> linalg.det(A) >>> linalg.norm(A) @@ -290,10 +286,9 @@ \begin{frame}[fragile] \frametitle{Linear Algebra ...} - Try it! \begin{lstlisting} - >>> A = sp.mat(np.arange(1,10)) - >>> A.shape=3,3 + >>> A = sp.array(sp.arange(1,10)) + >>> A.shape = 3,3 >>> linalg.lu(A) >>> linalg.eig(A) >>> linalg.eigvals(A) @@ -302,6 +297,7 @@ \begin{frame}[fragile] \frametitle{Solving Linear Equations} + \vspace{-0.2in} \begin{align*} 3x + 2y - z & = 1 \\ 2x - 2y + 4z & = -2 \\ @@ -309,10 +305,12 @@ \end{align*} To Solve this, \begin{lstlisting} - >>> A = sp.mat([[3,2,-1],[2,-2,4] + >>> A = sp.array([[3,2,-1],[2,-2,4] ,[-1,1/2,-1]]) - >>> B = sp.mat([[1],[-2],[0]]) - >>> linalg.solve(A,B) + >>> b = sp.array([1,-2,0]) + >>> x = linalg.solve(A,b) + >>> Ax = sp.dot(A,x) + >>> sp.allclose(Ax, b) \end{lstlisting} \inctime{15} \end{frame} @@ -343,8 +341,8 @@ \begin{lstlisting} >>> def dx_dt(x,t): return -np.exp(-t)*x**2 ->>> t=np.linspace(0,2,100) ->>> x=integrate.odeint(dx_dt, 2, t) +>>> t = np.linspace(0,2,100) +>>> x = integrate.odeint(dx_dt, 2, t) >>> plt.plot(x,t) \end{lstlisting} \inctime{10} @@ -353,7 +351,6 @@ \subsection{Interpolation} \begin{frame}[fragile] \frametitle{Interpolation} - Try it! \begin{lstlisting} >>> from scipy import interpolate >>> interpolate.interp1d? @@ -373,9 +370,9 @@ Plot the Cubic Spline of $sin(x)$ \begin{lstlisting} >>> tck = interpolate.splrep(x,y) ->>> X = np.arange(0,2*np.pi,np.pi/50) ->>> Y = interpolate.splev(X,tck,der=0) ->>> plt.plot(x,y,'o',x,y,X,Y) +>>> xs = np.arange(0,2*np.pi,np.pi/50) +>>> ys = interpolate.splev(X,tck,der=0) +>>> plt.plot(x,y,'o',x,y,xs,ys) >>> plt.show() \end{lstlisting} \inctime{10} @@ -404,13 +401,13 @@ \begin{lstlisting} >>> from scipy import signal, ndimage >>> from scipy import lena ->>> A=lena().astype('float32') ->>> B=signal.medfilt2d(A) +>>> A = lena().astype('float32') +>>> B = signal.medfilt2d(A) >>> imshow(B) \end{lstlisting} Zooming an array - uses spline interpolation \begin{lstlisting} ->>> b=ndimage.zoom(A,0.5) +>>> b = ndimage.zoom(A,0.5) >>> imshow(b) \end{lstlisting} \inctime{5} diff -r 691608044ae7 -r a749db24e73b day2/session3.tex --- a/day2/session3.tex Fri Oct 09 17:14:00 2009 +0530 +++ b/day2/session3.tex Sat Oct 10 08:03:50 2009 +0530 @@ -229,6 +229,14 @@ \end{frame} \begin{frame} + \frametitle{Live in your dialogs} + \vspace*{0.1in} + \begin{center} + \hspace*{-0.2in}\pgfimage[width=2.5in]{MEDIA/m2/mlab_tui} + \end{center} +\end{frame} + +\begin{frame} {Exploring the documentation} \begin{center} \pgfimage[width=4in]{MEDIA/m2/m2_ug_doc}