306 \item NumPy array functions - square, average, sqrt |
306 \item NumPy array functions - square, average, sqrt |
307 \end{itemize} |
307 \end{itemize} |
308 \end{frame} |
308 \end{frame} |
309 |
309 |
310 \begin{frame}[fragile] |
310 \begin{frame}[fragile] |
|
311 \frametitle{Dealing with data whole-sale} |
|
312 \begin{lstlisting} |
|
313 In []: for t in T: |
|
314 ....: Tsq.append(t*t) |
|
315 \end{lstlisting} |
|
316 \begin{itemize} |
|
317 \item This is not very efficient |
|
318 \item We are squaring element after element |
|
319 \item We use arrays to make this efficient |
|
320 \end{itemize} |
|
321 \begin{lstlisting} |
|
322 In []: L = array(L) |
|
323 In []: T = array(T) |
|
324 In []: Tsq = T*T |
|
325 \end{lstlisting} |
|
326 \end{frame} |
|
327 |
|
328 \begin{frame}[fragile] |
|
329 \frametitle{Arrays} |
|
330 \begin{itemize} |
|
331 \item \typ{T} and \typ{L} are now arrays |
|
332 \item arrays are very efficient and powerful |
|
333 \item Very easy to perform element-wise operations |
|
334 \item \typ{+, -, *, /, \%} |
|
335 \item More about arrays later |
|
336 \end{itemize} |
|
337 \end{frame} |
|
338 |
|
339 \begin{frame}[fragile] |
|
340 \frametitle{Least Squares Fit} |
|
341 \vspace{-0.15in} |
|
342 \begin{figure} |
|
343 \includegraphics[width=4in]{data/L-Tsq-Line.png} |
|
344 \end{figure} |
|
345 \end{frame} |
|
346 |
|
347 \begin{frame}[fragile] |
311 \frametitle{Least Squares Fit} |
348 \frametitle{Least Squares Fit} |
312 \vspace{-0.15in} |
349 \vspace{-0.15in} |
313 \begin{figure} |
350 \begin{figure} |
314 \includegraphics[width=4in]{data/least-sq-fit.png} |
351 \includegraphics[width=4in]{data/least-sq-fit.png} |
315 \end{figure} |
352 \end{figure} |
316 \end{frame} |
|
317 |
|
318 \begin{frame}[fragile] |
|
319 \frametitle{Calculating $T^2$ Efficiently} |
|
320 \begin{lstlisting} |
|
321 In []: for t in T: |
|
322 ....: Tsq.append(t*t) |
|
323 \end{lstlisting} |
|
324 \begin{itemize} |
|
325 \item This is not very efficient |
|
326 \item We use arrays to make it efficient |
|
327 \end{itemize} |
|
328 \begin{lstlisting} |
|
329 In []: L = array(L) |
|
330 In []: T = array(T) |
|
331 In []: Tsq = T*T |
|
332 In []: plot(L, Tsq, 'o') |
|
333 \end{lstlisting} |
|
334 \end{frame} |
|
335 |
|
336 \begin{frame}[fragile] |
|
337 \frametitle{Arrays} |
|
338 \begin{itemize} |
|
339 \item \typ{T} and \typ{L} are now arrays |
|
340 \item arrays are very efficient and powerful |
|
341 \item Very easy to perform element-wise operations |
|
342 \item \typ{+, -, *, /, \%} |
|
343 \item More about arrays later |
|
344 \end{itemize} |
|
345 \end{frame} |
353 \end{frame} |
346 |
354 |
347 \begin{frame} |
355 \begin{frame} |
348 \frametitle{Least Square Fit Curve} |
356 \frametitle{Least Square Fit Curve} |
349 \begin{itemize} |
357 \begin{itemize} |