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