71
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
2 |
%Tutorial slides on Python.
|
|
3 |
%
|
|
4 |
% Author: FOSSEE
|
|
5 |
% Copyright (c) 2009, FOSSEE, IIT Bombay
|
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
7 |
|
|
8 |
\documentclass[14pt,compress]{beamer}
|
|
9 |
%\documentclass[draft]{beamer}
|
|
10 |
%\documentclass[compress,handout]{beamer}
|
|
11 |
%\usepackage{pgfpages}
|
|
12 |
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
|
|
13 |
|
|
14 |
% Modified from: generic-ornate-15min-45min.de.tex
|
|
15 |
\mode<presentation>
|
|
16 |
{
|
|
17 |
\usetheme{Warsaw}
|
|
18 |
\useoutertheme{infolines}
|
|
19 |
\setbeamercovered{transparent}
|
|
20 |
}
|
|
21 |
|
|
22 |
\usepackage[english]{babel}
|
|
23 |
\usepackage[latin1]{inputenc}
|
|
24 |
%\usepackage{times}
|
|
25 |
\usepackage[T1]{fontenc}
|
|
26 |
|
|
27 |
% Taken from Fernando's slides.
|
|
28 |
\usepackage{ae,aecompl}
|
|
29 |
\usepackage{mathpazo,courier,euler}
|
|
30 |
\usepackage[scaled=.95]{helvet}
|
|
31 |
|
|
32 |
\definecolor{darkgreen}{rgb}{0,0.5,0}
|
|
33 |
|
|
34 |
\usepackage{listings}
|
|
35 |
\lstset{language=Python,
|
|
36 |
basicstyle=\ttfamily\bfseries,
|
|
37 |
commentstyle=\color{red}\itshape,
|
|
38 |
stringstyle=\color{darkgreen},
|
|
39 |
showstringspaces=false,
|
|
40 |
keywordstyle=\color{blue}\bfseries}
|
|
41 |
|
|
42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
43 |
% Macros
|
|
44 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
|
|
45 |
\newcommand{\emphbar}[1]
|
|
46 |
{\begin{beamercolorbox}[rounded=true]{emphbar}
|
|
47 |
{#1}
|
|
48 |
\end{beamercolorbox}
|
|
49 |
}
|
|
50 |
\newcounter{time}
|
|
51 |
\setcounter{time}{0}
|
|
52 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
|
|
53 |
|
|
54 |
\newcommand{\typ}[1]{\lstinline{#1}}
|
|
55 |
|
|
56 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
|
|
57 |
|
|
58 |
% Title page
|
|
59 |
\title{Python for Scientific Computing : Least Square Fit}
|
|
60 |
|
|
61 |
\author[FOSSEE] {FOSSEE}
|
|
62 |
|
|
63 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
|
|
64 |
\date{}
|
|
65 |
|
|
66 |
% DOCUMENT STARTS
|
|
67 |
\begin{document}
|
|
68 |
|
|
69 |
\begin{frame}
|
|
70 |
\maketitle
|
|
71 |
\end{frame}
|
|
72 |
|
|
73 |
\begin{frame}
|
|
74 |
\frametitle{About the Session}
|
|
75 |
\begin{block}{Goal}
|
|
76 |
Finding least square fit of given data-set
|
|
77 |
\end{block}
|
|
78 |
\begin{block}{Checklist}
|
|
79 |
\begin{itemize}
|
|
80 |
\item pendulum.txt
|
|
81 |
\end{itemize}
|
|
82 |
\end{block}
|
|
83 |
\end{frame}
|
|
84 |
|
|
85 |
\begin{frame}[fragile]
|
|
86 |
\frametitle{$L$ vs. $T^2$ - Scatter}
|
|
87 |
\vspace{-0.15in}
|
|
88 |
\begin{figure}
|
|
89 |
\includegraphics[width=4in]{data/L-Tsq-points}
|
|
90 |
\end{figure}
|
|
91 |
\end{frame}
|
|
92 |
|
|
93 |
\begin{frame}[fragile]
|
|
94 |
\frametitle{$L$ vs. $T^2$ - Line}
|
|
95 |
\vspace{-0.15in}
|
|
96 |
\begin{figure}
|
|
97 |
\includegraphics[width=4in]{data/L-Tsq-Line}
|
|
98 |
\end{figure}
|
|
99 |
\end{frame}
|
|
100 |
|
|
101 |
\begin{frame}[fragile]
|
|
102 |
\frametitle{$L$ vs. $T^2$ }
|
|
103 |
\frametitle{$L$ vs. $T^2$ - Least Square Fit}
|
|
104 |
\vspace{-0.15in}
|
|
105 |
\begin{figure}
|
|
106 |
\includegraphics[width=4in]{data/least-sq-fit}
|
|
107 |
\end{figure}
|
|
108 |
\end{frame}
|
|
109 |
|
|
110 |
\begin{frame}
|
|
111 |
\frametitle{Least Square Fit Curve}
|
|
112 |
\begin{center}
|
|
113 |
\begin{itemize}
|
|
114 |
\item $L \alpha T^2$
|
|
115 |
\item Best Fit Curve $\rightarrow$ Linear
|
|
116 |
\begin{itemize}
|
|
117 |
\item Least Square Fit
|
|
118 |
\end{itemize}
|
|
119 |
\item \typ{lstsq()}
|
|
120 |
\end{itemize}
|
|
121 |
\end{center}
|
|
122 |
\end{frame}
|
|
123 |
|
|
124 |
\begin{frame}[fragile]
|
|
125 |
\frametitle{\typ{lstsq}}
|
|
126 |
\begin{itemize}
|
|
127 |
\item We need to fit a line through points for the equation $T^2 = m \cdot L+c$
|
|
128 |
\item In matrix form, the equation can be represented as $T_{sq} = A \cdot p$, where $T_{sq}$ is
|
|
129 |
$\begin{bmatrix}
|
|
130 |
T^2_1 \\
|
|
131 |
T^2_2 \\
|
|
132 |
\vdots\\
|
|
133 |
T^2_N \\
|
|
134 |
\end{bmatrix}$
|
|
135 |
, A is
|
|
136 |
$\begin{bmatrix}
|
|
137 |
L_1 & 1 \\
|
|
138 |
L_2 & 1 \\
|
|
139 |
\vdots & \vdots\\
|
|
140 |
L_N & 1 \\
|
|
141 |
\end{bmatrix}$
|
|
142 |
and p is
|
|
143 |
$\begin{bmatrix}
|
|
144 |
m\\
|
|
145 |
c\\
|
|
146 |
\end{bmatrix}$
|
|
147 |
\item We need to find $p$ to plot the line
|
|
148 |
\end{itemize}
|
|
149 |
\end{frame}
|
|
150 |
|
|
151 |
\begin{frame}[fragile]
|
|
152 |
\frametitle{Summary}
|
|
153 |
\begin{block}{}
|
|
154 |
|
|
155 |
\end{block}
|
|
156 |
\end{frame}
|
|
157 |
|
|
158 |
\begin{frame}
|
|
159 |
\frametitle{Thank you!}
|
|
160 |
\begin{block}{}
|
|
161 |
This session is part of \textcolor{blue}{FOSSEE} project funded by:
|
|
162 |
\begin{center}
|
|
163 |
\textcolor{blue}{NME through ICT from MHRD, Govt. of India}.
|
|
164 |
\end{center}
|
|
165 |
\end{block}
|
|
166 |
\end{frame}
|
|
167 |
|
|
168 |
\end{document}
|