author | Puneeth Chaganti <punchagan@fossee.in> |
Mon, 26 Oct 2009 19:18:04 +0530 | |
changeset 172 | 72bd110ab42f |
parent 167 | 5f13be28532d |
child 170 | 36ed5cdf5fde |
permissions | -rw-r--r-- |
115 | 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
142
57e0f0fd3317
Made usage of FOSSEE consistent, in comments also.
Puneeth Chaganti <punchagan@fossee.in>
parents:
137
diff
changeset
|
2 |
%Tutorial slides on Python. |
115 | 3 |
% |
142
57e0f0fd3317
Made usage of FOSSEE consistent, in comments also.
Puneeth Chaganti <punchagan@fossee.in>
parents:
137
diff
changeset
|
4 |
% Author: FOSSEE |
57e0f0fd3317
Made usage of FOSSEE consistent, in comments also.
Puneeth Chaganti <punchagan@fossee.in>
parents:
137
diff
changeset
|
5 |
% Copyright (c) 2009, FOSSEE, IIT Bombay |
115 | 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{split} |
|
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} |
|
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
31 |
\usepackage{amsmath} |
115 | 32 |
|
33 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
|
34 |
||
35 |
\usepackage{listings} |
|
36 |
\lstset{language=Python, |
|
37 |
basicstyle=\ttfamily\bfseries, |
|
38 |
commentstyle=\color{red}\itshape, |
|
39 |
stringstyle=\color{darkgreen}, |
|
40 |
showstringspaces=false, |
|
41 |
keywordstyle=\color{blue}\bfseries} |
|
42 |
||
43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
44 |
% Macros |
|
45 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
|
46 |
\newcommand{\emphbar}[1] |
|
47 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
|
48 |
{#1} |
|
49 |
\end{beamercolorbox} |
|
50 |
} |
|
51 |
\newcounter{time} |
|
52 |
\setcounter{time}{0} |
|
53 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
|
54 |
||
55 |
\newcommand{\typ}[1]{\lstinline{#1}} |
|
56 |
||
57 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
|
58 |
||
59 |
%%% This is from Fernando's setup. |
|
60 |
% \usepackage{color} |
|
61 |
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
|
62 |
% % Use and configure listings package for nicely formatted code |
|
63 |
% \usepackage{listings} |
|
64 |
% \lstset{ |
|
65 |
% language=Python, |
|
66 |
% basicstyle=\small\ttfamily, |
|
67 |
% commentstyle=\ttfamily\color{blue}, |
|
68 |
% stringstyle=\ttfamily\color{orange}, |
|
69 |
% showstringspaces=false, |
|
70 |
% breaklines=true, |
|
71 |
% postbreak = \space\dots |
|
72 |
% } |
|
73 |
||
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
75 |
% Title page |
|
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
76 |
\title[]{Least Squares Fit\\Statistical Plotting} |
115 | 77 |
|
78 |
\author[FOSSEE] {FOSSEE} |
|
79 |
||
80 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
|
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
125
diff
changeset
|
81 |
\date[] {31, October 2009\\Day 1, Session 3} |
115 | 82 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
83 |
||
84 |
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
|
85 |
%\logo{\pgfuseimage{iitmlogo}} |
|
86 |
||
87 |
||
88 |
%% Delete this, if you do not want the table of contents to pop up at |
|
89 |
%% the beginning of each subsection: |
|
90 |
\AtBeginSubsection[] |
|
91 |
{ |
|
92 |
\begin{frame}<beamer> |
|
93 |
\frametitle{Outline} |
|
94 |
\tableofcontents[currentsection,currentsubsection] |
|
95 |
\end{frame} |
|
96 |
} |
|
97 |
||
98 |
\AtBeginSection[] |
|
99 |
{ |
|
100 |
\begin{frame}<beamer> |
|
101 |
\frametitle{Outline} |
|
102 |
\tableofcontents[currentsection,currentsubsection] |
|
103 |
\end{frame} |
|
104 |
} |
|
105 |
||
106 |
\newcommand{\num}{\texttt{numpy}} |
|
107 |
||
108 |
||
109 |
% If you wish to uncover everything in a step-wise fashion, uncomment |
|
110 |
% the following command: |
|
111 |
%\beamerdefaultoverlayspecification{<+->} |
|
112 |
||
113 |
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
|
114 |
||
115 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
116 |
% DOCUMENT STARTS |
|
117 |
\begin{document} |
|
118 |
||
119 |
\begin{frame} |
|
120 |
\maketitle |
|
121 |
\end{frame} |
|
122 |
||
123 |
%% \begin{frame} |
|
124 |
%% \frametitle{Outline} |
|
125 |
%% \tableofcontents |
|
126 |
%% % You might wish to add the option [pausesections] |
|
127 |
%% \end{frame} |
|
128 |
||
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
129 |
\begin{frame}[fragile] |
115 | 130 |
\frametitle{Least Squares Fit} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
131 |
\vspace{-0.15in} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
132 |
\begin{figure} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
133 |
\includegraphics[width=4in]{data/least-sq-fit.png} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
134 |
\end{figure} |
115 | 135 |
\end{frame} |
136 |
||
117
958e3e090c6b
Session 3 now compiles; errors corrected.
Puneeth Chaganti <punchagan@fossee.in>
parents:
116
diff
changeset
|
137 |
\begin{frame}[fragile] |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
138 |
\frametitle{Calculating $T^2$ Efficiently} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
139 |
\begin{lstlisting} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
140 |
In []: for t in T: |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
141 |
....: Tsq.append(t*t) |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
142 |
\end{lstlisting} |
115 | 143 |
\begin{itemize} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
144 |
\item This is not very efficient |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
145 |
\item We use arrays to make it efficient |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
146 |
\end{itemize} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
147 |
\begin{lstlisting} |
137 | 148 |
In []: L = array(L) |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
149 |
In []: T = array(T) |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
150 |
In []: Tsq = T*T |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
151 |
In []: plot(L, Tsq, 'o') |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
152 |
\end{lstlisting} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
153 |
\end{frame} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
154 |
|
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
155 |
\begin{frame}[fragile] |
115 | 156 |
\frametitle{Arrays} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
157 |
\begin{itemize} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
158 |
\item \typ{T} and \typ{L} are now arrays |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
159 |
\item arrays are very efficient and powerful |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
160 |
\item Very easy to perform element-wise operations |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
161 |
\item \typ{+, -, *, /, \%} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
162 |
\item More about arrays later |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
163 |
\end{itemize} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
164 |
\end{frame} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
165 |
|
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
166 |
\begin{frame} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
167 |
\frametitle{Least Square Fit Curve} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
168 |
\begin{itemize} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
169 |
\item $T^2$ and $L$ have a linear relationship |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
170 |
\item Hence, Least Square Fit Curve is a line |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
171 |
\item we shall use the \typ{lstsq} function |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
172 |
\end{itemize} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
173 |
\end{frame} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
174 |
|
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
175 |
\begin{frame}[fragile] |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
176 |
\frametitle{\typ{lstsq}} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
177 |
\begin{itemize} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
178 |
\item We need to fit a line through points for the equation $T^2 = m \cdot L+c$ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
179 |
\item The equation can be re-written as $T^2 = A \cdot p$ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
180 |
\item where A is |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
181 |
$\begin{bmatrix} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
182 |
L_1 & 1 \\ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
183 |
L_2 & 1 \\ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
184 |
\vdots & \vdots\\ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
185 |
L_N & 1 \\ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
186 |
\end{bmatrix}$ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
187 |
and p is |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
188 |
$\begin{bmatrix} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
189 |
m\\ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
190 |
c\\ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
191 |
\end{bmatrix}$ |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
192 |
\item We need to find $p$ to plot the line |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
193 |
\end{itemize} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
194 |
\end{frame} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
195 |
|
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
196 |
\begin{frame}[fragile] |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
197 |
\frametitle{Van der Monde Matrix} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
198 |
\begin{itemize} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
199 |
\item A is also called a Van der Monde matrix |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
200 |
\item It can be generated using \typ{vander} |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
201 |
\end{itemize} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
202 |
Van der Monde matrix of order M |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
203 |
\begin{equation*} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
204 |
\begin{bmatrix} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
205 |
l_1^{M-1} & \ldots & l_1 & 1 \\ |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
206 |
l_2^{M-1} & \ldots &l_2 & 1 \\ |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
207 |
\vdots & \ldots & \vdots & \vdots\\ |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
208 |
l_N^{M-1} & \ldots & l_N & 1 \\ |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
209 |
\end{bmatrix} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
210 |
\end{equation*} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
211 |
\begin{lstlisting} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
212 |
In []: A = vander(L,2) |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
213 |
\end{lstlisting} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
214 |
\end{frame} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
215 |
|
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
216 |
\begin{frame}[fragile] |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
217 |
\frametitle{\typ{lstsq} \ldots} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
218 |
\begin{itemize} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
219 |
\item Now use the \typ{lstsq} function |
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
220 |
\item Along with a lot of things, it returns the least squares solution |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
221 |
\end{itemize} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
222 |
\begin{lstlisting} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
125
diff
changeset
|
223 |
In []: coef, res, r, s = lstsq(A,Tsq) |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
224 |
\end{lstlisting} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
225 |
\end{frame} |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
226 |
|
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
227 |
\begin{frame}[fragile] |
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
228 |
\frametitle{Least Square Fit Line \ldots} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
229 |
We get the points of the line from \typ{coef} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
230 |
\begin{lstlisting} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
231 |
In []: Tline = coef[0]*L + coef[1] |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
232 |
\end{lstlisting} |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
233 |
\begin{itemize} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
234 |
\item Now plot Tline vs. L, to get the Least squares fit line. |
164
b03c0d1be31f
Changed Least squares fit in session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
161
diff
changeset
|
235 |
\end{itemize} |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
236 |
\begin{lstlisting} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
125
diff
changeset
|
237 |
In []: plot(L, Tline) |
116
cb91f43d2cbb
Added Least Square Fitting to Session3.
Puneeth Chaganti <punchagan@fossee.in>
parents:
115
diff
changeset
|
238 |
\end{lstlisting} |
115 | 239 |
\end{frame} |
240 |
||
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
241 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
242 |
\frametitle{Statistical Analysis and Parsing} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
243 |
Read the data supplied in \emph{sslc1.txt} and obtain the following statistics: |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
244 |
\begin{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
245 |
\item Average total marks scored in each region |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
246 |
\item Subject wise average score of each region |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
247 |
\item \alert{??Subject wise average score for all regions combined??} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
248 |
\item Find the subject wise standard deviation of scores for each region |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
249 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
250 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
251 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
252 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
253 |
\frametitle{Statistical Analysis and Parsing \ldots} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
254 |
Machinery Required - |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
255 |
\begin{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
256 |
\item File reading and parsing |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
257 |
\item NumPy arrays - sum by rows and sum by coloumns |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
258 |
\item Dictionaries |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
259 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
260 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
261 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
262 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
263 |
\frametitle{File reading and parsing} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
264 |
Understanding the structure of sslc1.txt |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
265 |
\begin{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
266 |
\item Each line in the file, i.e each row of a file is a single record. |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
267 |
\item Each record corresponds to a record of a single student |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
268 |
\item Each record consists of several fields separated by a ';' |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
269 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
270 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
271 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
272 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
273 |
\frametitle{File reading and parsing \ldots} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
274 |
Each record consists of: |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
275 |
\begin{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
276 |
\item Region Code |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
277 |
\item Roll Number |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
278 |
\item Name |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
279 |
\item Marks of 5 subjects |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
280 |
\item Total marks |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
281 |
\item Pass (P) |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
282 |
\item Withdrawn (W) |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
283 |
\item Fail (F) |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
284 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
285 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
286 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
287 |
\begin{frame}[fragile] |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
288 |
\frametitle{File reading and parsing \ldots} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
289 |
\begin{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
290 |
for record in open('sslc1.txt'): |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
291 |
fields = record.split(';') |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
292 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
293 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
294 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
295 |
\begin{frame}[fragile] |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
296 |
\frametitle{Dictionary - Building parsed data} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
297 |
\begin{itemize} |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
298 |
\item Let the parsed data be stored in dictionary \typ{data} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
299 |
\item \begin{lstlisting} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
300 |
data = {} # is an empty dictionary |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
301 |
\end{lstlisting} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
302 |
\item Index of a dictionary is called a \emph{key} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
303 |
\item \emph{Keys} of \typ{data} are strings - region codes |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
304 |
\item Value of a \emph{key} can be any Python object |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
305 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
306 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
307 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
308 |
\begin{frame}[fragile] |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
309 |
\frametitle{Dictionary - Building parsed data...} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
310 |
\begin{itemize} |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
311 |
\item In this problem let the value of a \emph{key} be another dictionary. |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
312 |
\item This dictionary contains: |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
313 |
\begin{itemize} |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
314 |
\item 'marks': A \emph{list} of NumPy arrays |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
315 |
\item 'total': Total marks of each student |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
316 |
\item 'P': Number of passes |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
317 |
\item 'F': Number of failures |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
318 |
\item 'W': Number of withdrawls |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
319 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
320 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
321 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
322 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
323 |
\begin{frame}[fragile] |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
324 |
\frametitle{Dictionary - Building parsed data \ldots} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
325 |
\small |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
326 |
\begin{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
327 |
data = {} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
328 |
for record in open('sslc1.txt'): |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
329 |
fields = record.split(';') |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
330 |
if fields[0] not in data: |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
331 |
data[fields[0]] = { |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
332 |
'marks': [], |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
333 |
'total': [], |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
334 |
'P': 0, |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
335 |
'F': 0, |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
336 |
'W': 0 |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
337 |
} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
338 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
339 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
340 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
341 |
\begin{frame}[fragile] |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
342 |
\frametitle{Dictionary - Building parsed data \ldots} |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
343 |
\begin{lstlisting} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
344 |
marks = [] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
345 |
for field in fields[3:8]: |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
346 |
score_str = field.strip() |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
347 |
score = 0 if score_str == 'AA' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
348 |
or score_str == 'AAA' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
349 |
or score_str == '' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
350 |
else int(score_str) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
351 |
marks.append(score) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
352 |
|
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
353 |
data[fields[0]]['marks'].append(marks) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
354 |
\end{lstlisting} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
355 |
\end{frame} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
356 |
|
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
357 |
\begin{frame}[fragile] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
358 |
\frametitle{Dictionary - Building parsed data \ldots} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
359 |
\begin{lstlisting} |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
360 |
total = 0 if score_str == 'AA' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
361 |
or score_str == 'AAA' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
362 |
or score_str == '' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
363 |
else int(fields[8]) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
364 |
data[fields[0]]['total'].append(total) |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
365 |
|
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
366 |
pfw_key = fields[9] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
367 |
or fields[10] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
368 |
or 'F' |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
369 |
data[fields[0]][pfw_key] += 1 |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
370 |
\end{lstlisting} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
371 |
\end{frame} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
372 |
|
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
373 |
\begin{frame}[fragile] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
374 |
\frametitle{Dictionary - Building parsed data \ldots} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
375 |
\begin{lstlisting} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
376 |
pfw_key = fields[9] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
377 |
or fields[10] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
378 |
or 'F' |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
379 |
data[fields[0]][pfw_key] += 1 |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
380 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
381 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
382 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
383 |
\begin{frame}[fragile] |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
384 |
\frametitle{Calculations} |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
385 |
\small |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
386 |
\begin{lstlisting} |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
387 |
for k in data: |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
388 |
data[k]['marks'] = array(data[k]['marks']) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
389 |
data[k]['total'] = array(data[k]['total']) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
390 |
|
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
391 |
data[k]['avg'] = average( |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
392 |
data[k]['total']) |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
393 |
marks = data[k]['marks'] |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
394 |
sub_avg = average(marks, axis=1) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
395 |
sub_std = sqrt(sum(square( |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
396 |
sub_avg[:,newaxis] - marks), axis=0) / |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
397 |
len(marks)) |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
398 |
data[k]['sub_avg'] = sub_avg |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
399 |
data[k]['sub_std'] = sub_std |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
400 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
401 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
402 |
|
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
403 |
\begin{frame}[fragile] |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
404 |
\frametitle{New Concepts} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
405 |
\begin{itemize} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
406 |
\item Dictionaries |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
407 |
\item Slicing lists |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
408 |
\item New type of conditional |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
409 |
\item NumPy arrays |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
410 |
\item Slicing NumPy arrays |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
411 |
\item NumPy array operations - square, average, sqrt |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
412 |
\end{itemize} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
413 |
\end{frame} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
414 |
|
115 | 415 |
\end{document} |