day2/session1.tex
author Santosh G. Vattam <vattam.santosh@gmail.com>
Sun, 04 Oct 2009 17:03:10 +0530
changeset 24 95fdc10975d5
parent 4 e5047bcbb608
child 6 1f9492506ba2
permissions -rw-r--r--
Session 1 slides cleaned up. Waiting for review.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
% Tutorial slides on Python.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     5
% Copyright (c) 2005-2008, Prabhu Ramachandran
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    15
\mode<presentation>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    16
{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    17
  \usetheme{Warsaw}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    18
  \useoutertheme{split}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
\usepackage[english]{babel}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
%\usepackage{times}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
% Taken from Fernando's slides.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    31
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
\definecolor{darkgreen}{rgb}{0,0.5,0}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    34
\usepackage{listings}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    35
\lstset{language=Python,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    36
    basicstyle=\ttfamily\bfseries,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    37
    commentstyle=\color{red}\itshape,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    38
  stringstyle=\color{darkgreen},
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    39
  showstringspaces=false,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    40
  keywordstyle=\color{blue}\bfseries}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    41
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    43
% Macros
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    45
\newcommand{\emphbar}[1]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    46
{\begin{beamercolorbox}[rounded=true]{emphbar} 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    47
      {#1}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    48
 \end{beamercolorbox}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    49
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    50
\newcounter{time}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    51
\setcounter{time}{0}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    52
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    53
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    54
\newcommand{\typ}[1]{\texttt{#1}}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    55
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    56
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    57
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
%%% This is from Fernando's setup.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    59
% \usepackage{color}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    60
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    61
% % Use and configure listings package for nicely formatted code
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    62
% \usepackage{listings}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
% \lstset{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    64
%    language=Python,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    65
%    basicstyle=\small\ttfamily,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    66
%    commentstyle=\ttfamily\color{blue},
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    67
%    stringstyle=\ttfamily\color{orange},
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    68
%    showstringspaces=false,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    69
%    breaklines=true,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    70
%    postbreak = \space\dots
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    71
% }
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    72
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    73
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    75
% Title page
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    76
\title[]{Matrices and Arrays\\ \& \\2D Plotting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    77
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    78
\author[Asokan \& Prabhu] {Asokan Pichai\\Prabhu Ramachandran}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    79
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    80
\institute[FOSSEE] {FOSSEE Team}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    81
\date[] {11, October 2009}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    83
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    84
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    85
%\logo{\pgfuseimage{iitmlogo}}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    86
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    87
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    88
%% Delete this, if you do not want the table of contents to pop up at
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    89
%% the beginning of each subsection:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    90
\AtBeginSubsection[]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    91
{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    92
  \begin{frame}<beamer>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    93
    \frametitle{Outline}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    94
    \tableofcontents[currentsection,currentsubsection]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    95
  \end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    96
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    97
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    98
\AtBeginSection[]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    99
{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   100
  \begin{frame}<beamer>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   101
    \frametitle{Outline}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   102
    \tableofcontents[currentsection,currentsubsection]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   103
  \end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   104
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   105
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   106
% If you wish to uncover everything in a step-wise fashion, uncomment
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   107
% the following command: 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
%\beamerdefaultoverlayspecification{<+->}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   110
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   111
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   112
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   113
% DOCUMENT STARTS
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   114
\begin{document}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   116
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   117
  \maketitle
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   118
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   119
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   120
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   121
  \frametitle{Outline}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   122
  \tableofcontents
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   123
  % You might wish to add the option [pausesections]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   126
\section{Matrices and Arrays}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   127
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   128
\subsection{Basic \typ{numpy} }
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   129
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   130
\newcommand{\num}{\texttt{numpy}}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   131
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   132
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   133
  \frametitle{The \num\ module}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   134
  \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   135
      \item Why?
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   136
  \item What:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   137
    \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   138
    \item An efficient and powerful array type for various common data
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   139
      types
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   140
    \item Abstracts out the most commonly used standard operations on
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   141
      arrays
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   142
    \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   143
  \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   144
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   145
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   146
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   147
  \frametitle{Examples of \num}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   148
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   149
# Simple array math example
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   150
>>> from numpy import *
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   151
>>> a = array([1,2,3,4])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   152
>>> b = array([2,3,4,5])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   153
>>> a*2 + b + 1 # Basic math!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   154
array([5, 8, 11, 14])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   155
# Pi and e are defined.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   156
>>> x = linspace(0.0, 10.0, 1000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   157
>>> x *= 2*pi/10 # inplace.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   158
# apply functions to array.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   159
>>> y = sin(x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   160
\end{lstlisting}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   161
\inctime{5}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   162
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   163
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   164
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   165
  \frametitle{Basic concepts}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   166
  \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   167
  \item fixed size (\typ{arr.size});
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   168
  \item Same type (\typ{arr.dtype}) of data
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   169
  \item arbitrary dimensionality
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   170
  \item \typ{arr.shape}: size in each dimension
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   171
  \item \alert{Note:} \typ{len(arr) != arr.size} in general
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   172
  \item \alert{Note:} By default array operations are performed
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   173
    \alert{elementwise}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   174
  \item Indices, slicing: just like lists 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   175
  \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   176
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   177
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   178
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   179
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   180
  \frametitle{More examples of \num}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   181
\vspace*{-8pt}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   182
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   183
>>> x = array([1., 2, 3, 4])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   184
>>> size(x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   185
4
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   186
>>> x.dtype # What is a.dtype?
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   187
dtype('float64')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   188
>>> x.shape
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   189
(4,)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   190
>>> print rank(x), x.itemsize
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   191
1 8
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   192
>>> x[0] = 10
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   193
>>> print x[0], x[-1]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   194
10.0 4.0
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   195
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   196
    
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   197
\inctime{10}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   198
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   199
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   200
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   201
  \frametitle{Multi-dimensional arrays}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   202
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   203
>>> a = array([[ 0, 1, 2, 3],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   204
...            [10,11,12,13]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   205
>>> a.shape # (rows, columns)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   206
(2, 4)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   207
# Accessing and setting values
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   208
>>> a[1,3] 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   209
13
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   210
>>> a[1,3] = -1
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   211
>>> a[1] # The second row
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   212
array([10,11,12,-1])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   213
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   214
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   215
\end{frame}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   216
\begin{frame}[fragile]
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   217
  \frametitle{Array math}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   218
  \begin{itemize}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   219
  \item Basic \alert{elementwise} math (given two arrays \typ{a, b}):
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   220
      \typ{+, -, *, /, \%}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   221
  \item Inplace operators: \typ{a += b}, or \typ{add(a, b,
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   222
      a)} etc.
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   223
  \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)},
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   224
    \typ{less (<)}, \typ{greater (>)} etc.
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   225
  \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x),
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   226
      exp(x), sqrt(x)} etc.
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   227
  \item \typ{sum(x, axis=0), product(x, axis=0)} 
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   228
  \item \typ{dot(a, bp)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   229
  \end{itemize}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   230
  \inctime{10}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   231
\end{frame}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   232
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   233
\subsection{Array Creation \& Slicing, Striding Arrays}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   234
\begin{frame}[fragile]
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   235
  \frametitle{Array creation functions}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   236
  \begin{itemize}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   237
  \item \typ{array(object, dtype=None, \ldots)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   238
  \item \typ{arange(start, stop=None, step=1 \ldots)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   239
  \item \typ{linspace(start, stop, num=50, \ldots)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   240
  \item \typ{ones(shape, dtype=None, \ldots)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   241
  \item \typ{zeros(shape, dtype=float,\ldots)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   242
  \item \typ{identity(n)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   243
  \item \typ{empty(shape, dtype=float,\ldots)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   244
  \item \typ{ones\_like(x)}, 
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   245
  \item \typ{zeros\_like(x)}, \typ{empty\_like(x)}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   246
  \end{itemize}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   247
\end{frame}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   248
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   249
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   250
  \frametitle{Slicing arrays}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   251
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   252
>>> a = array([[1,2,3], [4,5,6], 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   253
               [7,8,9]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   254
>>> a[0,1:3]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   255
array([2, 3])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   256
>>> a[1:,1:]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   257
array([[5, 6],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   258
       [8, 9]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   259
>>> a[:,2]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   260
array([3, 6, 9])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   261
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   262
\end{frame}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   263
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   264
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   265
  \frametitle{Striding arrays}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   266
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   267
>>> a[0::2,0::2]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   268
array([[1, 3],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   269
       [7, 9]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   270
# Slices are references to the 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   271
# same memory!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   272
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   273
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   274
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   275
\begin{frame}[fragile]
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   276
\frametitle{Random Numbers}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   277
\begin{lstlisting}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   278
>>> np.random.rand(3,2)
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   279
array([[ 0.96276665,  0.77174861],
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   280
       [ 0.35138557,  0.61462271],
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   281
       [ 0.16789255,  0.43848811]])
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   282
>>> np.random.randint(1,100)
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   283
42
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   284
\end{lstlisting}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   285
\inctime{15}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   286
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   287
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   288
\begin{frame}[fragile]
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   289
  \frametitle{Problem set 1.0}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   290
\inctime{15}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   291
\end{frame}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   292
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   293
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   294
\section{2D Plotting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   295
\subsection{Getting Started}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   296
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   297
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   298
    {IPython's \typ{pylab} mode}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   299
\begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   300
    \item \typ{pylab}: convenient 2D plotting interface to MPL
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   301
    \item Immediate use: \typ{ipython -pylab}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   302
    \item Imports all of pylab for you!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   303
    \item Allows for interactive plotting
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   304
\end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   305
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   306
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   307
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   308
    \frametitle{Basic 2D plotting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   309
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   310
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   311
>>> x = linspace(0, 2*pi, 1000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   312
>>> plot(x, sin(x)) 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   313
>>> plot(x, sin(x), 'ro')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   314
>>> xlabel(r'$\chi$', color='g')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   315
# LaTeX markup!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   316
>>> ylabel(r'sin($\chi$)', color='r')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   317
>>> title('Simple figure', fontsize=20)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   318
>>> savefig('/tmp/test.eps')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   319
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   320
\begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   321
  \item Also: PNG, PDF, PS, EPS, SVG, PDF
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   322
\end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   323
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   324
       
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   325
\subsection{Plots - Lines, Labels and Legends}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   326
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   327
  \frametitle{Basic plotting \ldots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   328
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   329
# Set properties of objects:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   330
>>> l, = plot(x, sin(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   331
# Why "l,"?
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   332
>>> setp(l, linewidth=2.0, color='r')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   333
>>> l.set_linewidth(2.0)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   334
>>> draw() # Redraw.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   335
>>> setp(l) # Print properties
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   336
>>> clf() # Clear figure.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   337
>>> close() # Close figure.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   338
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   339
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   340
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   341
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   342
    \frametitle{Multiple figures}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   343
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   344
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   345
>>> figure(1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   346
>>> plot(x, sin(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   347
>>> figure(2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   348
>>> plot(x, tanh(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   349
>>> figure(1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   350
>>> title('Easy as 1,2,3')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   351
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   352
    
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   353
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   354
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   355
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   356
  \frametitle{Legends and Annotation}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   357
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   358
>>> plot(x, cos(5*x), 'r--', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   359
         label='cosine')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   360
>>> plot(x, sin(5*x), 'g--', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   361
         label='sine')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   362
>>> legend() 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   363
# Or use:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   364
>>> legend(['cosine', 'sine'])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   365
# Annotation:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   366
>>> text(1,0, '(1,0)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   367
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   368
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   369
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   370
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   371
    \frametitle{More commands \ldots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   372
    \begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   373
# semilog, loglog 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   374
>>> x = 10.**(-arange(100)*0.1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   375
>>> semilogx(x, x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   376
>>> semilogy(x, x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   377
>>> loglog(x, x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   378
>>> loglog(x, x*x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   379
    \end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   380
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   381
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   382
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   383
    \frametitle{More plots \ldots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   384
    \begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   385
>>> clf()
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   386
>>> t = arange(0.1, 4, 0.1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   387
>>> s = exp(-t)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   388
>>> e = 0.1*abs(randn(len(s)))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   389
>>> errorbar(t, s, e)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   390
# Scatter plots
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   391
>>> clf()
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   392
>>> t = randn(len(e))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   393
>>> scatter(t, e, c=s)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   394
    \end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   395
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   396
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   397
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   398
    \frametitle{Note: \typ{pylab} in Python scripts}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   399
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   400
import pylab
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   401
x = pylab.linspace(0, 20, 1000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   402
pylab.plot(x, pylab.sin(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   403
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   404
# Can also use:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   405
from pylab import linspace, sin, plot
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   406
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   407
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   408
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   409
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   410
\subsection{Types of Plots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   411
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   412
  \frametitle{X-Y plot}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   413
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   414
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   415
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   416
    \includegraphics[height=2in, interpolate=true]{data/xyplot}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   417
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   418
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   419
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   420
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   421
t1 = arange(0.0, 5.0, 0.1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   422
t2 = arange(0.0, 5.0, 0.02)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   423
t3 = arange(0.0, 2.0, 0.01)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   424
subplot(211)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   425
plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   426
     t2, cos(2*pi*t2)*exp(-t2), 'k')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   427
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   428
title('A tale of 2 subplots')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   429
ylabel('Damped')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   430
subplot(212)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   431
plot(t3, cos(2*pi*t3), 'r--')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   432
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   433
xlabel('time (s)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   434
ylabel('Undamped')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   435
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   436
    \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   437
  \end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   438
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   439
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   440
\begin{frame}[fragile] \frametitle{Semi-log and log-log plots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   441
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   442
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   443
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   444
  \includegraphics[height=2in, interpolate=true]{data/log}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   445
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   446
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   447
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   448
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   449
dt = 0.01
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   450
t = arange(dt, 20.0, dt)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   451
subplot(311)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   452
semilogy(t, exp(-t/5.0))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   453
ylabel('semilogy')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   454
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   455
subplot(312)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   456
semilogx(t, sin(2*pi*t))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   457
ylabel('semilogx')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   458
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   459
# minor grid on too
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   460
gca().xaxis.grid(True, which='minor')  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   461
subplot(313)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   462
loglog(t, 20*exp(-t/10.0), basex=4)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   463
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   464
ylabel('loglog base 4 on x')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   465
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   466
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   467
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   468
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   469
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   470
\begin{frame}[fragile] \frametitle{Errorbar}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   471
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   472
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   473
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   474
  \includegraphics[height=2in, interpolate=true]{data/errorbar}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   475
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   476
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   477
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   478
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   479
t = arange(0.1, 4, 0.1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   480
s = exp(-t)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   481
e = 0.1*abs(randn(len(s)))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   482
f = 0.1*abs(randn(len(s)))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   483
g = 2*e
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   484
h = 2*f
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   485
errorbar(t, s, [e,g], f, fmt='o')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   486
xlabel('Distance (m)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   487
ylabel('Height (m)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   488
title('Mean and standard error '\
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   489
      'as a function of distance')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   490
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   491
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   492
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   493
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   494
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   495
\begin{frame}[fragile] \frametitle{Histogram}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   496
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   497
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   498
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   499
  \includegraphics[height=2in, interpolate=true]{data/histogram}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   500
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   501
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   502
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   503
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   504
mu, sigma = 100, 15
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   505
x = mu + sigma*randn(10000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   506
# the histogram of the data
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   507
n, bins, patches = hist(x, 100, normed=1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   508
# add a 'best fit' line
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   509
y = normpdf( bins, mu, sigma)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   510
l = plot(bins, y, 'r--', linewidth=2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   511
xlim(40, 160)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   512
xlabel('Smarts')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   513
ylabel('P')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   514
title(r'$\rm{IQ:}\/ \mu=100,\/ \sigma=15$')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   515
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   516
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   517
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   518
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   519
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   520
\begin{frame}[fragile] \frametitle{Bar charts}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   521
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   522
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   523
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   524
  \includegraphics[height=2in, interpolate=true]{data/barchart}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   525
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   526
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   527
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   528
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   529
N = 5
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   530
menMeans = (20, 35, 30, 35, 27)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   531
menStd =   ( 2,  3,  4,  1,  2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   532
# the x locations for the groups
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   533
ind = arange(N) 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   534
# the width of the bars
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   535
width = 0.35       
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   536
p1 = bar(ind, menMeans, width, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   537
         color='r', yerr=menStd)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   538
womenMeans = (25, 32, 34, 20, 25)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   539
womenStd =   ( 3,  5,  2,  3,  3)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   540
p2 = bar(ind+width, womenMeans, width, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   541
         color='y', yerr=womenStd)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   542
ylabel('Scores')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   543
title('Scores by group and gender')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   544
xticks(ind+width, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   545
       ('G1', 'G2', 'G3', 'G4', 'G5'))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   546
xlim(-width,len(ind))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   547
yticks(arange(0,41,10))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   548
legend((p1[0], p2[0]), 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   549
       ('Men', 'Women'), shadow=True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   550
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   551
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   552
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   553
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   554
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   555
\begin{frame}[fragile] \frametitle{Pie charts}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   556
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   557
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   558
    \hspace*{-0.4in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   559
  \includegraphics[height=2.0in, interpolate=true]{data/piechart}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   560
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   561
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   562
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   563
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   564
# make a square figure and axes
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   565
figure(1, figsize=(8,8))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   566
ax = axes([0.1, 0.1, 0.8, 0.8])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   567
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   568
fracs = [15,30,45, 10]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   569
explode=(0, 0.05, 0, 0)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   570
pie(fracs, explode=explode, labels=labels, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   571
    autopct='%1.1f%%', shadow=True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   572
title('Raining Hogs and Dogs', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   573
      bbox={'facecolor':'0.8', 'pad':5})
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   574
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   575
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   576
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   577
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   578
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   579
\begin{frame}[fragile] \frametitle{Scatter plots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   580
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   581
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   582
    \hspace*{-0.4in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   583
  \includegraphics[height=2in, interpolate=true]{data/scatter}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   584
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   585
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   586
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   587
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   588
N = 30
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   589
x = 0.9*rand(N)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   590
y = 0.9*rand(N)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   591
# 0 to 10 point radiuses
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   592
area = pi*(10 * rand(N))**2 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   593
volume = 400 + rand(N)*450
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   594
scatter(x,y,s=area, marker='o', c=volume, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   595
        alpha=0.75)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   596
xlabel(r'$\Delta_i$', size='x-large')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   597
ylabel(r'$\Delta_{i+1}$', size='x-large')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   598
title(r'Volume and percent change')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   599
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   600
colorbar()
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   601
savefig('scatter')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   602
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   603
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   604
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   605
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   606
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   607
\begin{frame}[fragile] \frametitle{Polar}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   608
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   609
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   610
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   611
  \includegraphics[height=2in, interpolate=true]{data/polar}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   612
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   613
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   614
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   615
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   616
figure(figsize=(8,8))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   617
ax = axes([0.1, 0.1, 0.8, 0.8], 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   618
          polar=True, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   619
          axisbg='#d5de9c')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   620
r = arange(0,1,0.001)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   621
theta = 2*2*pi*r
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   622
polar(theta, r, color='#ee8d18', lw=3)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   623
# the radius of the grid labels
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   624
setp(ax.thetagridlabels, y=1.075) 
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   625
title(r'$\theta=4\pi r$', fontsize=20)
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   626
\end{lstlisting}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   627
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   628
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   629
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   630
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   631
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   632
\begin{frame}[fragile] \frametitle{Contours}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   633
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   634
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   635
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   636
  \includegraphics[height=2in, interpolate=true]{data/contour}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   637
    \column{0.525\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   638
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   639
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   640
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   641
x = arange(-3.0, 3.0, 0.025)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   642
y = arange(-2.0, 2.0, 0.025)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   643
X, Y = meshgrid(x, y)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   644
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   645
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   646
# difference of Gaussians
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   647
Z = 10.0 * (Z2 - Z1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   648
im = imshow(Z, interpolation='bilinear', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   649
            origin='lower',
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   650
            cmap=cm.gray, extent=(-3,3,-2,2))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   651
levels = arange(-1.2, 1.6, 0.2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   652
# label every second level
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   653
clabel(CS, levels[1::2],  inline=1,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   654
       fmt='%1.1f', fontsize=14)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   655
CS = contour(Z, levels,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   656
             origin='lower',
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   657
             linewidths=2,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   658
             extent=(-3,3,-2,2))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   659
# make a colorbar for the contour lines
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   660
CB = colorbar(CS, shrink=0.8, extend='both')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   661
title('Lines with colorbar')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   662
hot(); flag()
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   663
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   664
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   665
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   666
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   667
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   668
\begin{frame}[fragile] \frametitle{Velocity vectors}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   669
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   670
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   671
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   672
  \includegraphics[height=2in, interpolate=true]{data/quiver}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   673
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   674
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   675
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   676
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   677
X,Y = meshgrid(arange(0,2*pi,.2),
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   678
               arange(0,2*pi,.2) )
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   679
U = cos(X)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   680
V = sin(Y)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   681
Q = quiver(X[::3, ::3], Y[::3, ::3], 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   682
           U[::3, ::3], V[::3, ::3],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   683
           color='r', units='x', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   684
           linewidths=(2,), 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   685
           edgecolors=('k'), 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   686
           headaxislength=5 )
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   687
qk = quiverkey(Q, 0.5, 0.03, 1, '1 m/s', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   688
               fontproperties=
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   689
               {'weight': 'bold'})
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   690
axis([-1, 7, -1, 7])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   691
title('triangular head; scale '\
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   692
      'with x view; black edges')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   693
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   694
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   695
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   696
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   697
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   698
\begin{frame}[fragile] \frametitle{Maps}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   699
  \includegraphics[height=2.5in, interpolate=true]{data/plotmap}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   700
  \begin{center}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   701
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   702
    For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   703
  \end{center}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   704
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   705
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   706
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   707
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   708
  \frametitle{More information}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   709
  \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   710
  \item More information here: \url{http://matplotlib.sf.net}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   711
  \item \url{http://matplotlib.sf.net/tutorial.html}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   712
  \item \url{http://matplotlib.sf.net/screenshots.html}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   713
  \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   714
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   715
  \inctime{25}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   716
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   717
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   718
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   719
  \frametitle{Problem set 1.0}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   720
  \begin{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   721
      \item Write a function that plots any n-gon given \typ{n}.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   722
      \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   723
          $k=2.5, 3.5$ and $4$
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   724
\end{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   725
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   726
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   727
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   728
  \frametitle{Problem set 1.1}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   729
  \begin{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   730
      \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) =
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   731
          kx(1-x)$.  Plot the successive iterates of this process.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   732
      \item Plot this using a cobweb plot as follows:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   733
          \begin{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   734
              \item Start at $(x_0, 0)$
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   735
              \item Draw line to $(x_i, f(x_i))$; 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   736
              \item Set $x_{i+1} = f(x_i)$
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   737
              \item Draw line to $(x_i, x_i)$
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   738
              \item Repeat from 2 for as long as you want 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   739
          \end{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   740
    \end{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   741
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   742
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   743
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   744
  \frametitle{Problem set 1.2}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   745
  \begin{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   746
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   747
      \item Plot the Koch snowflake.  Write a function to generate the
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   748
          necessary points given the two points constituting a line.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   749
          \pause
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   750
          \begin{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   751
              \item Split the line into 4 segments.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   752
              \item The first and last segments are trivial.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   753
              \item To rotate the point you can use complex numbers,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   754
                  recall that $z e^{j \theta}$ rotates a point $z$ in 2D
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   755
                  by $\theta$.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   756
              \item Do this for all line segments till everything is
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   757
                  done.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   758
          \end{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   759
      \item Show rate of convergence for a first and second order finite
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   760
          difference of sin(x)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   761
\end{enumerate}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   762
\inctime{30}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   763
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   764
\end{document}