day1/session3.tex
author Puneeth Chaganti <punchagan@fossee.in>
Wed, 14 Oct 2009 20:05:22 +0530
changeset 117 958e3e090c6b
parent 116 cb91f43d2cbb
child 120 055b199c46c2
permissions -rw-r--r--
Session 3 now compiles; errors corrected.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
115
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
% Tutorial slides on Python.
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     5
% Copyright (c) 2005-2009, Prabhu Ramachandran
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    15
\mode<presentation>
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    16
{
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    17
  \usetheme{Warsaw}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    18
  \useoutertheme{split}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
\usepackage[english]{babel}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
%\usepackage{times}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
% Taken from Fernando's slides.
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
116
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
    31
\usepackage{amsmath}
115
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
\definecolor{darkgreen}{rgb}{0,0.5,0}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    34
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    35
\usepackage{listings}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    36
\lstset{language=Python,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    37
    basicstyle=\ttfamily\bfseries,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    38
    commentstyle=\color{red}\itshape,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    39
  stringstyle=\color{darkgreen},
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    40
  showstringspaces=false,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    41
  keywordstyle=\color{blue}\bfseries}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    42
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    43
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
% Macros
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    45
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    46
\newcommand{\emphbar}[1]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    47
{\begin{beamercolorbox}[rounded=true]{emphbar} 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    48
      {#1}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    49
 \end{beamercolorbox}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    50
}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    51
\newcounter{time}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    52
\setcounter{time}{0}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    53
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    54
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    55
\newcommand{\typ}[1]{\lstinline{#1}}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    56
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    57
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    59
%%% This is from Fernando's setup.
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    60
% \usepackage{color}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    61
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    62
% % Use and configure listings package for nicely formatted code
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
% \usepackage{listings}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    64
% \lstset{
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    65
%    language=Python,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    66
%    basicstyle=\small\ttfamily,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    67
%    commentstyle=\ttfamily\color{blue},
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    68
%    stringstyle=\ttfamily\color{orange},
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    69
%    showstringspaces=false,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    70
%    breaklines=true,
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    71
%    postbreak = \space\dots
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    72
% }
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    73
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    75
% Title page
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    76
\title[]{Arrays \& Least Squares Fit}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    77
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    78
\author[FOSSEE] {FOSSEE}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    79
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    80
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    81
\date[] {31, October 2009}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    83
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    84
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    85
%\logo{\pgfuseimage{iitmlogo}}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    86
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    87
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    88
%% Delete this, if you do not want the table of contents to pop up at
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    89
%% the beginning of each subsection:
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    90
\AtBeginSubsection[]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    91
{
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    92
  \begin{frame}<beamer>
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    93
    \frametitle{Outline}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    94
    \tableofcontents[currentsection,currentsubsection]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    95
  \end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    96
}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    97
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    98
\AtBeginSection[]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    99
{
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   100
  \begin{frame}<beamer>
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   101
    \frametitle{Outline}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   102
    \tableofcontents[currentsection,currentsubsection]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   103
  \end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   104
}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   105
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   106
\newcommand{\num}{\texttt{numpy}}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   107
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
% If you wish to uncover everything in a step-wise fashion, uncomment
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   110
% the following command: 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   111
%\beamerdefaultoverlayspecification{<+->}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   112
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   113
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   114
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   116
% DOCUMENT STARTS
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   117
\begin{document}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   118
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   119
\begin{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   120
  \maketitle
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   121
\end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   122
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   123
%% \begin{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
%%   \frametitle{Outline}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
%%   \tableofcontents
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   126
%%   % You might wish to add the option [pausesections]
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   127
%% \end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   128
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   129
\begin{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   130
\frametitle{Least Squares Fit}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   131
In this session - 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   132
\begin{itemize}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   133
\item We shall plot a least squares fit curve for time-period(T) squared vs. length(L) plot of a Simple Pendulum. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   134
\item Given a file containing L and T values
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   135
\end{itemize}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   136
\end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   137
117
958e3e090c6b Session 3 now compiles; errors corrected.
Puneeth Chaganti <punchagan@fossee.in>
parents: 116
diff changeset
   138
\begin{frame}[fragile]
115
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   139
\frametitle{Least Squares Fit \ldots}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   140
Machinery Required -
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   141
\begin{itemize}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   142
\item Reading files and parsing data
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   143
\item Plotting points, lines
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   144
\item Calculating the Coefficients of the Least Squares Fit curve
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   145
\begin{itemize}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   146
  \item Arrays
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   147
\end{itemize}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   148
\end{itemize}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   149
\end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   150
116
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   151
\begin{frame}[fragile]
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   152
\frametitle{Reading pendulum.txt}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   153
\begin{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   154
  \item The file has two columns
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   155
  \item Column1 - L; Column2 - T
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   156
\end{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   157
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   158
In []: L = []
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   159
In []: T = []
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   160
In []: for line in open('pendulum.txt'):
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   161
  ....     len, t = line.split()
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   162
  ....     L.append(float(len))
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   163
  ....     T.append(float(t))
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   164
\end{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   165
We now have two lists L and T
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   166
\end{frame}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   167
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   168
\begin{frame}[fragile]
117
958e3e090c6b Session 3 now compiles; errors corrected.
Puneeth Chaganti <punchagan@fossee.in>
parents: 116
diff changeset
   169
\frametitle{Calculating $T^2$}
116
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   170
\begin{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   171
\item Each element of the list T must be squared
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   172
\item Iterating over each element of the list works
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   173
\item But very slow \ldots
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   174
\item Instead, we use arrays
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   175
\end{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   176
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   177
In []: array(L)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   178
In []: T = array(T)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   179
In []: Tsq = T*T
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   180
In []: plot(L, Tsq, 'o')
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   181
\end{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   182
\end{frame}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   183
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   184
\begin{frame}[fragile]
115
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   185
\frametitle{Arrays}
116
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   186
\begin{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   187
\item T is now a \typ{numpy array}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   188
\item \typ{numpy} arrays are very efficient and powerful 
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   189
\item Very easy to perform element-wise operations
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   190
\item \typ{+, -, *, /, \%}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   191
\item More about arrays later
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   192
\end{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   193
\end{frame}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   194
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   195
\begin{frame}[fragile]
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   196
\frametitle{Least Square Polynomial}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   197
\begin{enumerate}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   198
\item $T^2 = \frac{4\pi^2}{g}L$
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   199
\item $T^2$ and $L$ have a linear relationship
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   200
\item We find an approximate solution to $Ax = y$, where A is the Van der Monde matrix to get coefficients of the least squares fit line. 
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   201
\end{enumerate}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   202
\end{frame}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   203
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   204
\begin{frame}[fragile]
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   205
\frametitle{Van der Monde Matrix}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   206
Van der Monde matrix of order M
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   207
\begin{equation*}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   208
  \begin{bmatrix}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   209
  l_1^{M-1} & \ldots & l_1 & 1 \\
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   210
  l_2^{M-1} & \ldots &l_2 & 1 \\
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   211
  \vdots & \ldots & \vdots & \vdots\\
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   212
  l_N^{M-1} & \ldots & l_N & 1 \\
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   213
  \end{bmatrix}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   214
\end{equation*}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   215
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   216
In []: A=vander(L,2)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   217
\end{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   218
\end{frame}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   219
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   220
\begin{frame}[fragile]
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   221
\frametitle{Least Square Fit Line}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   222
\begin{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   223
\item We use the \typ{lstsq} function of pylab
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   224
\item It returns the 
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   225
\begin{enumerate}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   226
\item Least squares solution
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   227
\item Sum of residues
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   228
\item Rank of matrix A
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   229
\item Singular values of A
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   230
\end{enumerate}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   231
\end{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   232
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   233
coeffs, res, rank, sing = lstsq(A,Tsq)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   234
\end{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   235
\end{frame}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   236
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   237
\begin{frame}[fragile]
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   238
\frametitle{Least Square Fit Line \ldots}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   239
\begin{itemize}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   240
\item Use the poly1d function of pylab, to create a function for the line equation using the coefficients obtained
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   241
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   242
p=poly1d(coeffs)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   243
\end{lstlisting}
117
958e3e090c6b Session 3 now compiles; errors corrected.
Puneeth Chaganti <punchagan@fossee.in>
parents: 116
diff changeset
   244
\item Get new $T^2$ values using the function \typ{p} obtained
116
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   245
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   246
Tline = p(L)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   247
\end{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   248
\item Now plot Tline vs. L, to get the Least squares fit line. 
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   249
\begin{lstlisting}
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   250
plot(L, Tline)
cb91f43d2cbb Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents: 115
diff changeset
   251
\end{lstlisting}
117
958e3e090c6b Session 3 now compiles; errors corrected.
Puneeth Chaganti <punchagan@fossee.in>
parents: 116
diff changeset
   252
\end{itemize}
115
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   253
\end{frame}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   254
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   255
\end{document}
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   256
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   257
Least squares: Smooth curve fit. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   258
Array Operations: Mean, average (etc region wise like district wise and state wise from SSLC.txt) 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   259
Subject wise average. Introduce idea of dictionary. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   260
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   261
Session 3
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   262
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   263
import scipy
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   264
from scipy import linalg.
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   265
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   266
choose some meaningful plot. ??
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   267
Newton's law of cooling. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   268
u, v, f - optics
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   269
hooke's law
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   270
Least fit curves. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   271
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   272
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   273
Choose a named problem. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   274
ODE - first order. Whatever. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   275
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   276
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   277
arrays, etc etc. 
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   278
sum, average, mean. whatever. statistical
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   279
sslc data
66709e58f765 Added session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   280
numpy load text??