day1/session4.tex
changeset 304 c53251e506cc
parent 293 f7d7b5565232
child 318 e75d3c993ed5
equal deleted inserted replaced
303:26f5e864a135 304:c53251e506cc
   501 \item We need to find $p$ to plot the line
   501 \item We need to find $p$ to plot the line
   502 \end{itemize}
   502 \end{itemize}
   503 \end{frame}
   503 \end{frame}
   504 
   504 
   505 \begin{frame}[fragile]
   505 \begin{frame}[fragile]
       
   506 \frametitle{Getting $L$ and $T^2$}
       
   507 If you \alert{closed} IPython after session 2
       
   508 \begin{lstlisting}
       
   509 In []: l = []
       
   510 In []: t = []
       
   511 In []: for line in open('pendulum.txt'):
       
   512   ....     point = line.split()
       
   513   ....     l.append(float(point[0]))
       
   514   ....     t.append(float(point[1]))
       
   515   ....
       
   516   ....
       
   517 \end{lstlisting}
       
   518 \end{frame}
       
   519  
       
   520 \begin{frame}[fragile]
   506 \frametitle{Generating $A$}
   521 \frametitle{Generating $A$}
   507 \begin{lstlisting}
   522 \begin{lstlisting}
   508 In []: A = array([L, ones_like(L)])
   523 In []: A = array([l, ones_like(l)])
   509 In []: A = A.T
   524 In []: A = A.T
   510 \end{lstlisting}
   525 \end{lstlisting}
   511 %% \begin{itemize}
   526 %% \begin{itemize}
   512 %% \item A is also called a Van der Monde matrix
   527 %% \item A is also called a Van der Monde matrix
   513 %% \item It can also be generated using \typ{vander}
   528 %% \item It can also be generated using \typ{vander}
   531 
   546 
   532 \begin{frame}[fragile]
   547 \begin{frame}[fragile]
   533 \frametitle{Least Square Fit Line \ldots}
   548 \frametitle{Least Square Fit Line \ldots}
   534 We get the points of the line from \typ{coef}
   549 We get the points of the line from \typ{coef}
   535 \begin{lstlisting}
   550 \begin{lstlisting}
   536 In []: Tline = coef[0]*L + coef[1]
   551 In []: Tline = coef[0]*l + coef[1]
   537 \end{lstlisting}
   552 \end{lstlisting}
   538 \begin{itemize}
   553 \begin{itemize}
   539 \item Now plot Tline vs. L, to get the Least squares fit line. 
   554 \item Now plot \typ{Tline} vs. \typ{l}, to get the Least squares fit line. 
   540 \end{itemize}
   555 \end{itemize}
   541 \begin{lstlisting}
   556 \begin{lstlisting}
   542 In []: plot(L, Tline)
   557 In []: plot(l, Tline)
   543 \end{lstlisting}
   558 \end{lstlisting}
   544 \end{frame}
   559 \end{frame}
   545 
   560 
   546 \begin{frame}[fragile]
   561 \begin{frame}[fragile]
   547 \frametitle{Least Squares Fit}
   562 \frametitle{Least Squares Fit}