author | Madhusudan.C.S <madhusudancs@gmail.com> |
Wed, 28 Oct 2009 20:33:01 +0530 | |
changeset 251 | 457b67834245 |
parent 249 | 135062d6f91f |
child 252 | 359f77927931 |
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} |
|
239
8953675dc056
Added slide numbers.
Puneeth Chaganti <punchagan@fossee.in>
parents:
229
diff
changeset
|
18 |
\useoutertheme{infolines} |
115 | 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 |
|
240
5a96cf81bdc5
Changed titles of Day1 slides.
Puneeth Chaganti <punchagan@fossee.in>
parents:
239
diff
changeset
|
76 |
\title[Statistics]{Python for Science and Engg: Statistics} |
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 |
||
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
129 |
\section{Processing voluminous data} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
130 |
\begin{frame} |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
131 |
\frametitle{More on data processing} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
132 |
\begin{block}{} |
192
1574b3bc6be7
Changed the focus of the statistics
rivermaker@RivermakerMBP.local
parents:
185
diff
changeset
|
133 |
We have a huge--1m records--data file.\\How do we do \emph{efficient} statistical computations, that is find mean, median, mode, standard deveiation etc; draw pie charts? |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
134 |
\end{block} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
135 |
\end{frame} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
136 |
|
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
137 |
|
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
138 |
\begin{frame} |
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
139 |
\frametitle{Statistical Analysis: Problem statement} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
140 |
Read the data supplied in \emph{sslc1.txt} and carry out the following: |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
141 |
\begin{enumerate} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
142 |
\item Draw a pie chart representing the proportion of students who scored more than 90\% in each region in Science. |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
143 |
\item Draw a pie chart representing the proportion of students who scored more than 90\% in each subject across regions. |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
144 |
\item Print mean, median, mode and standard deviation of math scores for all regions combined. |
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
145 |
\end{enumerate} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
146 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
147 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
148 |
\begin{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
149 |
\frametitle{Problem statement: explanation} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
150 |
\emphbar{Draw a pie chart representing the proportion of students who scored more than 90\% in each region in Science.} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
151 |
\begin{enumerate} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
152 |
\item Complete(100\%) data - Number of students who scored more than 90\% in Science |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
153 |
\item Each slice - Number of students who scored more than 90\% in Science in one region |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
154 |
\end{enumerate} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
155 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
156 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
157 |
\begin{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
158 |
\frametitle{Problem statement: explanation} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
159 |
\emphbar{Draw a pie chart representing the proportion of students who scored more than 90\% in each subject across regions.} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
160 |
\begin{enumerate} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
161 |
\item Complete(100\%) data - Number of students who scored more than 90\% across all regions |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
162 |
\item Each slice - Number of students who scored more than 90\% in each subject across all regions |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
163 |
\end{enumerate} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
164 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
165 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
166 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
167 |
\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
|
168 |
Machinery Required - |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
169 |
\begin{itemize} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
170 |
\item File reading |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
171 |
\item Parsing |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
172 |
\item Dictionaries |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
173 |
\item NumPy arrays |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
174 |
\item Statistical operations |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
175 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
176 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
177 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
178 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
179 |
\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
|
180 |
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
|
181 |
\begin{itemize} |
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
182 |
\item One line in file corresponds to a student's details |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
183 |
\item aka record |
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
184 |
\item Each record consists of fields separated by ';' |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
185 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
186 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
187 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
188 |
\begin{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
189 |
\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
|
190 |
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
|
191 |
\begin{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
192 |
\item Region Code |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
193 |
\item Roll Number |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
194 |
\item Name |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
195 |
\item Marks of 5 subjects: English, Hindi, Maths, Science, Social |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
196 |
\item Total marks |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
197 |
\item Pass/Fail (P/F) |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
198 |
\item Withdrawn (W) |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
199 |
\end{itemize} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
200 |
\inctime{5} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
201 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
202 |
|
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
203 |
\subsection{Data processing} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
204 |
\begin{frame}[fragile] |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
205 |
\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
|
206 |
\begin{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
207 |
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
|
208 |
fields = record.split(';') |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
209 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
210 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
211 |
|
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
212 |
\subsection{Dictionary} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
213 |
\begin{frame}[fragile] |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
214 |
\frametitle{Dictionary: Introduction} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
215 |
\begin{itemize} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
216 |
\item lists index: 0 \ldots n |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
217 |
\item dictionaries index using strings |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
218 |
\end{itemize} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
219 |
\begin{block}{Example} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
220 |
d = \{ ``Hitchhiker's guide'' : 42, |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
221 |
``Terminator'' : ``I'll be back''\}\\ |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
222 |
d[``Terminator''] => ``I'll be back'' |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
223 |
\end{block} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
224 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
225 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
226 |
\begin{frame}[fragile] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
227 |
\frametitle{Dictionary: Introduction} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
228 |
\begin{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
229 |
In [1]: d = {"Hitchhiker's guide" : 42, |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
230 |
"Terminator" : "I'll be back"} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
231 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
232 |
In [2]: d["Hitchhiker's guide"] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
233 |
Out[2]: 42 |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
234 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
235 |
In [3]: "Hitchhiker's guide" in d |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
236 |
Out[3]: True |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
237 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
238 |
In [4]: "Guido" in d |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
239 |
Out[4]: False |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
240 |
\end{lstlisting} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
241 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
242 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
243 |
\begin{frame}[fragile] |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
244 |
\frametitle{Dictionary: Introduction} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
245 |
\begin{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
246 |
In [5]: d.keys() |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
247 |
Out[5]: ['Terminator', "Hitchhiker's |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
248 |
guide"] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
249 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
250 |
In [6]: d.values() |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
251 |
Out[6]: ["I'll be back", 42] |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
252 |
\end{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
253 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
254 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
255 |
\begin{frame}[fragile] |
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
256 |
\frametitle{Back to lists: Iterating} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
257 |
\begin{itemize} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
258 |
\item Python's \kwrd{for} loop iterates through list items |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
259 |
\item In other languages (C/C++) we run through indices and pick items from the array using these indices |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
260 |
\item In Python, while iterating through list items current position is not available |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
261 |
\end{itemize} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
262 |
\begin{block}{Iterating through indices} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
263 |
What if we want the index of an item of a list? |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
264 |
\end{block} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
265 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
266 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
267 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
268 |
\begin{frame}[fragile] |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
269 |
\frametitle{enumerate: Iterating through list indices} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
270 |
\begin{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
271 |
In [1]: names = ["Guido","Alex", "Tim"] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
272 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
273 |
In [2]: for i, name in enumerate(names): |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
274 |
...: print i, name |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
275 |
...: |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
276 |
0 Guido |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
277 |
1 Alex |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
278 |
2 Tim |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
279 |
\end{lstlisting} |
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
280 |
\inctime{5} |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
281 |
\end{frame} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
282 |
|
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
283 |
\begin{frame}[fragile] |
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
284 |
\frametitle{Continuing with our Dictionary} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
285 |
Let our dictionary be: |
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
286 |
\begin{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
287 |
science = {} # is an empty dictionary |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
288 |
\end{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
289 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
290 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
291 |
\begin{frame}[fragile] |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
292 |
\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
|
293 |
\begin{itemize} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
294 |
\item \emph{Keys} of \emph{science} will be region codes |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
295 |
\item Value of a \emph{science} will be the number students who scored more than 90\% in that region |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
296 |
\end{itemize} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
297 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
298 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
299 |
\begin{frame}[fragile] |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
300 |
\frametitle{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
|
301 |
\begin{lstlisting} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
302 |
from pylab import pie |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
303 |
|
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
304 |
science = {} |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
305 |
|
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
306 |
for record in open('sslc1.txt'): |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
307 |
record = record.strip() |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
308 |
fields = record.split(';') |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
309 |
|
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
310 |
region_code = fields[0].strip() |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
311 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
312 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
313 |
|
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
314 |
\begin{frame}[fragile] |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
315 |
\frametitle{Building parsed data \ldots} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
316 |
\begin{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
317 |
if region_code not in science: |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
318 |
science[region_code] = 0 |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
319 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
320 |
score_str = fields[4].strip() |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
321 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
322 |
score = int(score_str) if |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
323 |
score_str != 'AA' else 0 |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
324 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
325 |
if score > 90: |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
326 |
science[region_code] += 1 |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
327 |
\end{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
328 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
329 |
|
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
330 |
\subsection{Visualizing data} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
331 |
\begin{frame}[fragile] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
332 |
\frametitle{Pie charts} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
333 |
\small |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
334 |
\begin{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
335 |
figure(1) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
336 |
pie(science.values(), |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
337 |
labels=science.keys()) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
338 |
title('Students scoring 90% and above |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
339 |
in science by region') |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
340 |
savefig('/tmp/science.png') |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
341 |
\end{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
342 |
\begin{columns} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
343 |
\column{5.25\textwidth} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
344 |
\hspace*{1.1in} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
345 |
\includegraphics[height=2in, interpolate=true]{data/science} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
346 |
\column{0.8\textwidth} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
347 |
\end{columns} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
348 |
\inctime{5} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
349 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
350 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
351 |
\begin{frame}[fragile] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
352 |
\frametitle{Building data for all subjects \ldots} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
353 |
\begin{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
354 |
from pylab import pie |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
355 |
from scipy import mean, median, std |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
356 |
from scipy import stats |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
357 |
|
216
c6704d4a18bd
Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
212
diff
changeset
|
358 |
scores = [[], [], [], [], []] |
c6704d4a18bd
Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
212
diff
changeset
|
359 |
ninety_percents = [{}, {}, {}, {}, {}] |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
360 |
\end{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
361 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
362 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
363 |
\begin{frame}[fragile] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
364 |
\frametitle{Building data for all subjects \ldots} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
365 |
\begin{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
366 |
for record in open('sslc1.txt'): |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
367 |
record = record.strip() |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
368 |
fields = record.split(';') |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
369 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
370 |
region_code = fields[0].strip() |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
371 |
\end{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
372 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
373 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
374 |
\begin{frame}[fragile] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
375 |
\frametitle{Building data for all subjects \ldots} |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
376 |
\small |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
377 |
\begin{lstlisting} |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
378 |
for i, field in enumerate(fields[3:8]): |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
379 |
if region_code not in ninety_percents[i]: |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
380 |
ninety_percents[i][region_code] = 0 |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
381 |
|
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
382 |
score_str = field.strip() |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
383 |
score = int(score_str) if |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
384 |
score_str != 'AA' else 0 |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
385 |
|
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
386 |
scores[i].append(score) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
387 |
|
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
388 |
if score > 90: |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
389 |
ninety_percents[i][region_code] += 1 |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
390 |
\end{lstlisting} |
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
391 |
\end{frame} |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
392 |
|
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
393 |
\begin{frame}[fragile] |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
394 |
\frametitle{Consolidating data} |
125
99ca3cb18fd2
Session 3 Day 1, sslc data parsing obtaining statistics.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
120
diff
changeset
|
395 |
\begin{lstlisting} |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
396 |
subj_total = [] |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
397 |
for subject in ninety_percents: |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
398 |
subj_total.append(sum( |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
399 |
subject.values())) |
170
36ed5cdf5fde
Reorganized the slides for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
167
diff
changeset
|
400 |
\end{lstlisting} |
36ed5cdf5fde
Reorganized the slides for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
167
diff
changeset
|
401 |
\end{frame} |
36ed5cdf5fde
Reorganized the slides for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
167
diff
changeset
|
402 |
|
36ed5cdf5fde
Reorganized the slides for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
167
diff
changeset
|
403 |
\begin{frame}[fragile] |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
404 |
\frametitle{Pie charts} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
405 |
\begin{lstlisting} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
406 |
figure(2) |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
407 |
pie(subj_total, labels=['English', |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
408 |
'Hindi', 'Maths', 'Science', |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
409 |
'Social']) |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
410 |
title('Students scoring more than |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
411 |
90% by subject(All regions |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
412 |
combined).') |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
413 |
savefig('/tmp/all_regions.png') |
120
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
414 |
\end{lstlisting} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
415 |
\end{frame} |
055b199c46c2
Added NumPy array operations to session3 day1 for sslc1.txt.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
117
diff
changeset
|
416 |
|
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
417 |
\begin{frame}[fragile] |
184
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
418 |
\frametitle{Pie charts} |
9efa777af2e2
Reworked on Session 3 day 1 slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
178
diff
changeset
|
419 |
\includegraphics[height=3in, interpolate=true]{data/all_regions} |
166
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
420 |
\end{frame} |
ddfd95133adc
Taken task based approach for Session 3, day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
161
diff
changeset
|
421 |
|
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
422 |
\subsection{Obtaining statistics} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
423 |
\begin{frame}[fragile] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
424 |
\frametitle{Obtaining statistics} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
425 |
\begin{block}{Statistics: Mean} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
426 |
Obtain the mean of Math scores |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
427 |
\end{block} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
428 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
429 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
430 |
\begin{frame}[fragile] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
431 |
\frametitle{Obtaining statistics: Solution} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
432 |
\begin{block}{Statistics: Mean} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
433 |
Obtain the mean of Math scores |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
434 |
\end{block} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
435 |
\begin{lstlisting} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
436 |
math_scores = scores[2] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
437 |
total = 0 |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
438 |
for i, score in enumerate(math_scores): |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
439 |
total += score |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
440 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
441 |
mean = total / (i + 1) |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
442 |
print "Mean: ", mean |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
443 |
\end{lstlisting} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
444 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
445 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
446 |
\begin{frame}[fragile] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
447 |
\frametitle{Obtaining statistics: Another solution} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
448 |
\begin{block}{Statistics: Mean} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
449 |
Obtain the mean of Math scores |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
450 |
\end{block} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
451 |
\begin{lstlisting} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
452 |
math_scores = scores[2] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
453 |
mean = sum(math_scores) / |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
454 |
len(math_scores) |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
455 |
\end{lstlisting} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
456 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
457 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
458 |
\begin{frame}[fragile] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
459 |
\frametitle{NumPy arrays} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
460 |
\begin{itemize} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
461 |
\item NumPy provides arrays |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
462 |
\item arrays are very efficient and powerful |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
463 |
\item Very easy to perform element-wise operations - \typ{+, -, *, /, \%} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
464 |
\begin{lstlisting} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
465 |
In [1]: a = array([1, 2, 3]) |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
466 |
In [2]: b = array([4, 5, 6]) |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
467 |
|
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
468 |
In [3]: a + b |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
469 |
Out[3]: array([5, 7, 9]) |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
470 |
\end{lstlisting} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
471 |
\item Very easy to compute statistics |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
472 |
\end{itemize} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
473 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
474 |
|
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
475 |
\begin{frame}[fragile] |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
476 |
\frametitle{Obtaining statistics} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
477 |
\begin{lstlisting} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
478 |
math_scores = array(scores[2]) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
479 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
480 |
print "Mean: ", mean(math_scores) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
481 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
482 |
print "Median: ", median(math_scores) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
483 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
484 |
print "Mode: ", stats.mode(math_scores) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
485 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
486 |
print "Standard Deviation: ", |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
487 |
std(math_scores) |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
488 |
\end{lstlisting} |
229
5541c47bc2e8
Added sections, subsections and time estimates for session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
216
diff
changeset
|
489 |
\inctime{15} |
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
490 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
491 |
|
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
492 |
\begin{frame}[fragile] |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
493 |
\frametitle{What tools did we use?} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
494 |
\begin{itemize} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
495 |
\item Dictionaries for storing data |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
496 |
\item Facilities for drawing pie charts |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
497 |
\item NumPy arrays for efficient array manipulations |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
498 |
\item Functions for statistical computations - mean, median, mode, standard deviation |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
499 |
\end{itemize} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
500 |
\end{frame} |
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
501 |
|
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
502 |
\section{Least square fit} |
208
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
503 |
\begin{frame} |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
504 |
\frametitle{L vs $T^2$ \ldots} |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
505 |
Let's go back to the L vs $T^2$ plot |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
506 |
\begin{itemize} |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
507 |
\item We first look at obtaining $T^2$ from T |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
508 |
\item Then, we look at plotting a Least Squares fit |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
509 |
\end{itemize} |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
510 |
\end{frame} |
c663c8daa109
Reorganized slides of session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
205
diff
changeset
|
511 |
|
204
87f914f38ba1
Session 3 day 1, Statistical operations finalized.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
192
diff
changeset
|
512 |
\begin{frame}[fragile] |
178
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
513 |
\frametitle{Dealing with data whole-sale} |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
514 |
\begin{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
515 |
In []: for t in T: |
185
e59ab9ab1a89
Manual Merge with Mainline.
Puneeth Chaganti <punchagan@fossee.in>
parents:
184
diff
changeset
|
516 |
....: TSq.append(t*t) |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
517 |
\end{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
518 |
\begin{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
519 |
\item This is not very efficient |
178
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
520 |
\item We are squaring element after element |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
521 |
\item We use arrays to make this efficient |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
522 |
\end{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
523 |
\begin{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
524 |
In []: L = array(L) |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
525 |
In []: T = array(T) |
185
e59ab9ab1a89
Manual Merge with Mainline.
Puneeth Chaganti <punchagan@fossee.in>
parents:
184
diff
changeset
|
526 |
In []: TSq = T*T |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
527 |
\end{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
528 |
\end{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
529 |
|
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
530 |
\begin{frame}[fragile] |
178
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
531 |
\frametitle{Least Squares Fit} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
532 |
\vspace{-0.15in} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
533 |
\begin{figure} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
534 |
\includegraphics[width=4in]{data/L-Tsq-Line.png} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
535 |
\end{figure} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
536 |
\end{frame} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
537 |
|
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
538 |
\begin{frame}[fragile] |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
539 |
\frametitle{Least Squares Fit} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
540 |
\vspace{-0.15in} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
541 |
\begin{figure} |
210
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
542 |
\includegraphics[width=4in]{data/L-Tsq-points.png} |
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
543 |
\end{figure} |
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
544 |
\end{frame} |
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
545 |
|
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
546 |
\begin{frame}[fragile] |
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
547 |
\frametitle{Least Squares Fit} |
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
548 |
\vspace{-0.15in} |
2d41487bc6fe
Added an image for scatter plot of L vs T^2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
203
diff
changeset
|
549 |
\begin{figure} |
178
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
550 |
\includegraphics[width=4in]{data/least-sq-fit.png} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
551 |
\end{figure} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
552 |
\end{frame} |
8a3a9d98fa84
Changed functions section and some minor edits.
Puneeth Chaganti <punchagan@fossee.in>
parents:
174
diff
changeset
|
553 |
|
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
554 |
\begin{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
555 |
\frametitle{Least Square Fit Curve} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
556 |
\begin{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
557 |
\item $T^2$ and $L$ have a linear relationship |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
558 |
\item Hence, Least Square Fit Curve is a line |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
559 |
\item we shall use the \typ{lstsq} function |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
560 |
\end{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
561 |
\end{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
562 |
|
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
563 |
\begin{frame}[fragile] |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
564 |
\frametitle{\typ{lstsq}} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
565 |
\begin{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
566 |
\item We need to fit a line through points for the equation $T^2 = m \cdot L+c$ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
567 |
\item The equation can be re-written as $T^2 = A \cdot p$ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
568 |
\item where A is |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
569 |
$\begin{bmatrix} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
570 |
L_1 & 1 \\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
571 |
L_2 & 1 \\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
572 |
\vdots & \vdots\\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
573 |
L_N & 1 \\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
574 |
\end{bmatrix}$ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
575 |
and p is |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
576 |
$\begin{bmatrix} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
577 |
m\\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
578 |
c\\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
579 |
\end{bmatrix}$ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
580 |
\item We need to find $p$ to plot the line |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
581 |
\end{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
582 |
\end{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
583 |
|
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
584 |
\subsection{Van der Monde matrix generation} |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
585 |
\begin{frame}[fragile] |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
586 |
\frametitle{Van der Monde Matrix} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
587 |
\begin{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
588 |
\item A is also called a Van der Monde matrix |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
589 |
\item It can be generated using \typ{vander} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
590 |
\end{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
591 |
Van der Monde matrix of order M |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
592 |
\begin{equation*} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
593 |
\begin{bmatrix} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
594 |
l_1^{M-1} & \ldots & l_1 & 1 \\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
595 |
l_2^{M-1} & \ldots &l_2 & 1 \\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
596 |
\vdots & \ldots & \vdots & \vdots\\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
597 |
l_N^{M-1} & \ldots & l_N & 1 \\ |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
598 |
\end{bmatrix} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
599 |
\end{equation*} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
600 |
\begin{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
601 |
In []: A = vander(L,2) |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
602 |
\end{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
603 |
\end{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
604 |
|
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
605 |
\begin{frame}[fragile] |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
606 |
\frametitle{\typ{lstsq} \ldots} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
607 |
\begin{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
608 |
\item Now use the \typ{lstsq} function |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
609 |
\item Along with a lot of things, it returns the least squares solution |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
610 |
\end{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
611 |
\begin{lstlisting} |
185
e59ab9ab1a89
Manual Merge with Mainline.
Puneeth Chaganti <punchagan@fossee.in>
parents:
184
diff
changeset
|
612 |
In []: coef, res, r, s = lstsq(A,TSq) |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
613 |
\end{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
614 |
\end{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
615 |
|
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
616 |
\subsection{Plotting} |
174
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
617 |
\begin{frame}[fragile] |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
618 |
\frametitle{Least Square Fit Line \ldots} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
619 |
We get the points of the line from \typ{coef} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
620 |
\begin{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
621 |
In []: Tline = coef[0]*L + coef[1] |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
622 |
\end{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
623 |
\begin{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
624 |
\item Now plot Tline vs. L, to get the Least squares fit line. |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
625 |
\end{itemize} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
626 |
\begin{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
627 |
In []: plot(L, Tline) |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
628 |
\end{lstlisting} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
629 |
\end{frame} |
a43832c1edc2
Reordered Session 3 Day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
170
diff
changeset
|
630 |
|
249
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
631 |
\begin{frame}[fragile] |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
632 |
\frametitle{What did we learn?} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
633 |
\begin{itemize} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
634 |
\item Least square fit |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
635 |
\item Van der Monde matrix generation |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
636 |
\item Plotting the least square fit curve |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
637 |
\end{itemize} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
638 |
\end{frame} |
135062d6f91f
Fixed typos and hanging words in Session 3 day 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
240
diff
changeset
|
639 |
|
115 | 640 |
\end{document} |