author | Madhusudan.C.S <madhusudancs@gmail.com> |
Tue, 10 Nov 2009 16:27:03 +0530 | |
changeset 299 | d47d36d057a7 |
parent 284 | 3c191accbb32 |
child 295 | 39d7c4e14585 |
permissions | -rw-r--r-- |
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} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
\begin{document} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
\date{} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
6 |
\vspace{-1in} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
7 |
\begin{center} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
8 |
\LARGE{Statistics and Least square fit}\\ |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
9 |
\large{FOSSEE} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
10 |
\end{center} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
11 |
\section{Statistics} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
12 |
Dictionary |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
13 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
14 |
In [1]: d = {"Hitchhiker's guide" : 42, |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
15 |
....: "Terminator" : "I'll be back"} #Creation |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
16 |
In [2]: d["Hitchhiker's guide"] # Accessing a value with key |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
17 |
In [3]: "Hitchhiker's guide" in d #Checking for a key |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
18 |
In [4]: d.keys() # Obtaining List of Keys |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
19 |
In [5]: d.values() # Obtaining List of Values |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
20 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
21 |
Iterating through List indices |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
22 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
23 |
In [1]: names = ["Guido","Alex", "Tim"] |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
24 |
In [2]: for i, name in enumerate(names): |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
25 |
...: print i, name |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
26 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
27 |
|
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
28 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
In [1]: score = int(score_str) if score_str != 'AA' else 0 |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
30 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
Drawing Pie Charts |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
32 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
33 |
In [1]: pie(science.values(), labels=science.keys()) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
34 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
35 |
sum() and len() functions |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
36 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
37 |
In [1]: mean = sum(math_scores) / len(math_scores) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
38 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
39 |
Numpy Arrays |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
40 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
41 |
In [1]: a = array([1, 2, 3]) #Creating |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
42 |
In [2]: b = array([4, 5, 6]) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
43 |
In [3]: a + b #Sum; Element-wise |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
44 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
45 |
Numpy statistical operations |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
46 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
47 |
In [1]: mean(math_scores) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
48 |
In [2]: median(math_scores) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
49 |
In [3]: stats.mode(math_scores) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
50 |
In [4]: std(math_scores) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
51 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
52 |
Generating Van der Monde matrix |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
53 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
54 |
In [1]: A = vander(L, 2) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
55 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
56 |
Getting a Least Squares Fit curve |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
57 |
\begin{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
58 |
In [1]: coef, res, r, s = lstsq(A,TSq) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
59 |
In [2]: Tline = coef[0]*L + coef[1] |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
60 |
In [3]: plot(L, Tline) |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
61 |
\end{verbatim} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
62 |
\end{document} |
3c191accbb32
Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
63 |