day1/cheatsheet4.tex
author Shantanu <shantanu@fossee.in>
Wed, 18 Nov 2009 18:37:15 +0530
changeset 313 f5bcb974a665
parent 295 39d7c4e14585
child 315 141f3903d4e8
permissions -rwxr-xr-x
Initial changes to cheat sheet for session 2.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
\documentclass[12pt]{article}
295
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     2
\title{Matrices and Least Square Fit}
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
\author{FOSSEE}
295
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     4
\usepackage{listings}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     5
\lstset{language=Python,
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     6
    basicstyle=\ttfamily,
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     7
  commentstyle=\itshape\bfseries,
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     8
  showstringspaces=false,
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
     9
}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    10
\newcommand{\typ}[1]{\lstinline{#1}}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    11
\usepackage[english]{babel}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    12
\usepackage[latin1]{inputenc}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    13
\usepackage{times}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    14
\usepackage[T1]{fontenc}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    15
\usepackage{ae,aecompl}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    16
\usepackage{mathpazo,courier,euler}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    17
\usepackage[scaled=.95]{helvet}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    18
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
\begin{document}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
\date{}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
\vspace{-1in}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
\begin{center}
295
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    23
\LARGE{Matrices and Least Square Fit}\\
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
\large{FOSSEE}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
\end{center}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
\section{Matrices}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
Inputting a Matrix
295
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    28
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    29
In []: C = array([[1,1,2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    30
                  [2,4,1],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    31
                  [-1,3,7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    32
In []: B = ones_like(C)
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    33
In []: A = ones((3,2))
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    34
In []: I = identity(3)
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    35
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    36
Accessing Elements
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    37
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    38
In []: C[1,2]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    39
Out[]: 1
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    40
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    41
In []: C[1]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    42
Out[]: array([2, 4, 1])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    43
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    44
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    45
Changing elements
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    46
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    47
In []: C[1,1] = -2
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    48
In []: C
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    49
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    50
array([[ 1,  1,  2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    51
       [ 2, -2,  1],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    52
       [-1,  3,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    53
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    54
In []: C[1] = [0,0,0]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    55
In []: C
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    56
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    57
array([[ 1,  1,  2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    58
       [ 0,  0,  0],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    59
       [-1,  3,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    60
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    61
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    62
Slicing
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    63
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    64
In []: C[:,1]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    65
Out[]: array([1, 0, 3])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    66
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    67
In []: C[1,:]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    68
Out[]: array([0, 0, 0])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    69
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    70
In []: C[0:2,:]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    71
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    72
array([[1, 1, 2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    73
       [0, 0, 0]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    74
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    75
In []: C[1:3,:]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    76
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    77
array([[ 0,  0,  0],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    78
       [-1,  3,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    79
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    80
In []: C[:2,:]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    81
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    82
array([[1, 1, 2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    83
       [0, 0, 0]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    84
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    85
In []: C[1:,:]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    86
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    87
array([[ 0,  0,  0],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    88
       [-1,  3,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    89
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    90
In []: C[1:,:2]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    91
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    92
array([[ 0,  0],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    93
       [-1,  3]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    94
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    95
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    96
Striding
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    97
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    98
In []: C[::2,:]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
    99
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   100
array([[ 1,  1,  2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   101
       [-1,  3,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   102
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   103
In []: C[:,::2]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   104
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   105
xarray([[ 1,  2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   106
       [ 0,  0],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   107
       [-1,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   108
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   109
In []: C[::2,::2]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   110
Out[]: 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   111
array([[ 1,  2],
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   112
       [-1,  7]])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   113
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   114
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
Matrix Operations
295
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   116
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   117
In []: A.T # Transpose
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   118
In []: sum(A) # Sum of all elements
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   119
In []: A+B # Addition
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   120
In []: A*B # Product
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   121
In []: inv(A) # Inverse
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   122
In []: det(A) # Determinant
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   123
\end{lstlisting}
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
Eigen Values and Eigen Vectors
295
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   126
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   127
In []: eig(A) #Eigen Values and Vectors
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   128
In []: eigvals(A) #Eigen Values 
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   129
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   130
%% Norm
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   131
%% \begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   132
%% In []: norm(A)
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   133
%% \end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   134
%% Single Value Decomposition
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   135
%% \begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   136
%% In []: svd(A)
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   137
%% \end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   138
Least Square Fit Line
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   139
\begin{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   140
In []: A = array([L, ones_like(L)])
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   141
In []: A = A.T
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   142
In []: result = lstsq(A,TSq)
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   143
In []: coef = result[0]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   144
In []: Tline = coef[0]*L + coef[1]
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   145
In []: plot(L, Tline)
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   146
\end{lstlisting}
39d7c4e14585 Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 284
diff changeset
   147
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   148
\end{document}