day1/cheatsheet3.tex
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 06 Nov 2009 13:53:20 +0530
changeset 284 3c191accbb32
child 295 39d7c4e14585
permissions -rw-r--r--
Added Cheatsheets for day1.

\documentclass[12pt]{article}
\title{Interactive Plotting}
\author{FOSSEE}
\begin{document}
\date{}
\vspace{-1in}
\begin{center}
\LARGE{Statistics and Least square fit}\\
\large{FOSSEE}
\end{center}
\section{Statistics}
Dictionary
\begin{verbatim}
In [1]: d = {"Hitchhiker's guide" : 42, 
  ....:      "Terminator" : "I'll be back"} #Creation
In [2]: d["Hitchhiker's guide"] # Accessing a value with key
In [3]: "Hitchhiker's guide" in d #Checking for a key
In [4]: d.keys() # Obtaining List of Keys
In [5]: d.values() # Obtaining List of Values
\end{verbatim}
Iterating through List indices
\begin{verbatim}
In [1]: names = ["Guido","Alex", "Tim"]
In [2]: for i, name in enumerate(names):
   ...:     print i, name
\end{verbatim}

\begin{verbatim}
In [1]: score = int(score_str) if score_str != 'AA' else 0
\end{verbatim}
Drawing Pie Charts
\begin{verbatim}
In [1]: pie(science.values(), labels=science.keys())
\end{verbatim}
sum() and len() functions
\begin{verbatim}
In [1]: mean = sum(math_scores) / len(math_scores)
\end{verbatim}
Numpy Arrays
\begin{verbatim}
In [1]: a = array([1, 2, 3]) #Creating
In [2]: b = array([4, 5, 6])
In [3]: a + b #Sum; Element-wise
\end{verbatim}
Numpy statistical operations 
\begin{verbatim}
In [1]: mean(math_scores)
In [2]: median(math_scores)
In [3]: stats.mode(math_scores)
In [4]: std(math_scores)
\end{verbatim}
Generating Van der Monde matrix
\begin{verbatim}
In [1]: A = vander(L, 2)
\end{verbatim}
Getting a Least Squares Fit curve
\begin{verbatim}
In [1]: coef, res, r, s = lstsq(A,TSq)
In [2]: Tline = coef[0]*L + coef[1]
In [3]: plot(L, Tline)
\end{verbatim}
\end{document}