diff options
author | Puneeth Chaganti | 2009-10-10 08:03:50 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2009-10-10 08:03:50 +0530 |
commit | b2e65de0dddd0d194a927bc4f5340554fa8c6924 (patch) | |
tree | cc0e0a79cdd0a54831b1f9e7a88acc416adfc8b3 /day2/session2.tex | |
parent | 0ec47360f7bcfaf087afe0b5d4698698c47b82ba (diff) | |
download | workshops-more-scipy-b2e65de0dddd0d194a927bc4f5340554fa8c6924.tar.gz workshops-more-scipy-b2e65de0dddd0d194a927bc4f5340554fa8c6924.tar.bz2 workshops-more-scipy-b2e65de0dddd0d194a927bc4f5340554fa8c6924.zip |
Added Dialogs Slide; More edits to Day2 slides.
Diffstat (limited to 'day2/session2.tex')
-rw-r--r-- | day2/session2.tex | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/day2/session2.tex b/day2/session2.tex index 0f471f5..8b390cf 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -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} |