author | Santosh G. Vattam <vattam.santosh@gmail.com> |
Mon, 22 Feb 2010 14:32:01 +0530 | |
changeset 373 | f04eca8b2f3d |
parent 330 | 46533051b9d3 |
child 437 | 3547b6f299b4 |
permissions | -rwxr-xr-x |
284
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
1 |
\documentclass[12pt]{article} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
2 |
\title{Interactive Plotting} |
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 |
|
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
5 |
\usepackage{listings} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
6 |
\lstset{language=Python, |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
7 |
basicstyle=\ttfamily, |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
8 |
commentstyle=\itshape\bfseries, |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
9 |
showstringspaces=false, |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
10 |
} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
11 |
\newcommand{\typ}[1]{\lstinline{#1}} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
12 |
\usepackage[english]{babel} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
13 |
\usepackage[latin1]{inputenc} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
14 |
\usepackage{times} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
15 |
\usepackage[T1]{fontenc} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
16 |
\usepackage{ae,aecompl} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
17 |
\usepackage{mathpazo,courier,euler} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
18 |
\usepackage[scaled=.95]{helvet} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
19 |
|
284
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
20 |
\begin{document} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
21 |
\date{} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
22 |
\vspace{-1in} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
23 |
\begin{center} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
24 |
\LARGE{Statistics and Least square fit}\\ |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
25 |
\large{FOSSEE} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
26 |
\end{center} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
27 |
\section{Statistics} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
28 |
Dictionary |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
29 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
30 |
In []: d = {"Hitchhiker's guide" : 42, |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
31 |
....: "Terminator" : "I'll be back"} #Creation |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
32 |
In []: d["Hitchhiker's guide"] # Accessing a value with key |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
33 |
In []: "Hitchhiker's guide" in d #Checking for a key |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
34 |
In []: d.keys() # Obtaining List of Keys |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
35 |
In []: d.values() # Obtaining List of Values |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
36 |
\end{lstlisting} |
284
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
37 |
Iterating through List indices |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
38 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
39 |
In []: names = ["Guido","Alex", "Tim"] |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
40 |
In []: for i, name in enumerate(names): |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
41 |
...: print i, name |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
42 |
\end{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
43 |
Computing Mean value of `\texttt{g}' |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
44 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
45 |
In []: G = [] |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
46 |
In []: for line in open('pendulum.txt'): |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
47 |
.... points = line.split() |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
48 |
.... l = float(points[0]) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
49 |
.... t = float(points[1]) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
50 |
.... g = 4 * pi * pi * l / t * t |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
51 |
.... G.append(g) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
52 |
\end{lstlisting} |
284
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
53 |
sum() and len() functions |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
54 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
55 |
total = 0 |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
56 |
for g in G: |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
57 |
total += g |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
58 |
mean_g = total / len(g) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
59 |
|
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
60 |
mean_g = sum(G) / len(G) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
61 |
mean_g = mean(G) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
62 |
\end{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
63 |
\newpage |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
64 |
Ternary Operator |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
65 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
66 |
In []: score = int(score_str) if score_str != 'AA' else 0 |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
67 |
\end{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
68 |
Drawing Pie Charts |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
69 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
70 |
In []: pie(science.values(), labels=science.keys()) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
71 |
\end{lstlisting} |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
72 |
Arrays |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
73 |
\begin{lstlisting} |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
74 |
In []: a = array([1, 2, 3]) #Creating |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
75 |
In []: b = array([4, 5, 6]) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
76 |
In []: a + b #Sum; Element-wise |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
77 |
\end{lstlisting} |
284
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
78 |
Numpy statistical operations |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
79 |
\begin{lstlisting} |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
295
diff
changeset
|
80 |
In []: mean(math_scores) |
295
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
81 |
In []: median(math_scores) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
82 |
In []: std(math_scores) |
39d7c4e14585
Added all day 1 cheatsheets.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
284
diff
changeset
|
83 |
\end{lstlisting} |
284
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
84 |
\end{document} |