changes progress file
authoramit
Thu, 23 Sep 2010 12:51:32 +0530
changeset 203 846d71a4e915
parent 202 069d4e86207e (current diff)
parent 199 680a0692529f (diff)
child 204 65e5e2362bc9
changes progress file
getting_started_with_for.rst
progress.org
--- a/embellishing_a_plot.rst	Thu Sep 23 12:46:52 2010 +0530
+++ b/embellishing_a_plot.rst	Thu Sep 23 12:51:32 2010 +0530
@@ -56,7 +56,7 @@
 
 .. #[Madhu: diff again]
 
-To alter the thickness of the line, we use the =linewidth= argument in the plot
+To alter the thickness of the line, we use the ``linewidth`` argument in the plot
 command. Hence
 ::
 
@@ -168,7 +168,7 @@
 
 .. #[Madhu: Added "not". See the diff]
 
-We will now add a title to the plot by using the =title= command.
+We will now add a title to the plot by using the ``title`` command.
 ::
 
     title("Parabolic function -x^2+4x-5") 
@@ -176,7 +176,7 @@
 {{{ Show the plot window and point to the title }}}
 
 The figure now has a title which describes what the plot is. The
-=title= command as you can see, takes a string as an argument and sets
+``title`` command as you can see, takes a string as an argument and sets
 the title accordingly.
 
 .. #[Madhu: See the diff]
@@ -225,8 +225,8 @@
 
 {{{ Switch to plot window and show the xlabel }}}
 
-As you can see, =xlabel= command takes a string as an argument,
-similar to the =title= command and sets it as the label to x-axis.
+As you can see, ``xlabel`` command takes a string as an argument,
+similar to the ``title`` command and sets it as the label to x-axis.
 
 .. #[See the diff]
 
@@ -265,7 +265,7 @@
 
 {{{ Show the annotation that has appeared on the plot }}}
 
-As you can see, the first argument to =annotate= command is the name we would
+As you can see, the first argument to ``annotate`` command is the name we would
 like to mark the point as and the second argument is the co-ordinates of the
 point at which the name should appear. It is a sequence containing two numbers.
 The first is x co-ordinate and second is y co-ordinate.
--- a/getting_started_with_for.rst	Thu Sep 23 12:46:52 2010 +0530
+++ b/getting_started_with_for.rst	Thu Sep 23 12:51:32 2010 +0530
@@ -281,5 +281,5 @@
 
 ..  Author: Anoop Jacob Thomas <anoop@fossee.in>
     Reviewer 1: Nishanth
-    Reviewer 2:
+    Reviewer 2: Amit Sethi
     External reviewer:
--- a/loading-data-from-files.rst	Thu Sep 23 12:46:52 2010 +0530
+++ b/loading-data-from-files.rst	Thu Sep 23 12:51:32 2010 +0530
@@ -6,23 +6,15 @@
 
 {{{ Screen shows welcome slide }}}
 
-Until now, all the plots we have made use analytic functions. We have
-been using analytic functions to generate a sequence of points and
-plotting them, against another sequence of points. But, this is not
-what we do most often. We often require to plot points obtained from
-experimental observations.
-
-#[punch: the initial part of the paragraph may be removed, to make
-this a more generic LO?]
-
-In this tutorial we shall learn to read data from files and save it
-into sequences that can later be used to plot.
+We often require to plot points obtained from experimental
+observations. In this tutorial we shall learn to read data from files
+and save it into sequences that can later be used to plot.
 
 {{{ Show the outline for this tutorial }}} 
 
 We shall use the ``loadtxt`` command to load data from files. We will
-be looking at how to get multiple columns of data into multiple
-sequences.
+be looking at how to read a file with multiple columns of data and
+load each column of data into a sequence. 
 
 {{{ switch back to the terminal }}}
 
@@ -33,16 +25,22 @@
 
 Now, Let us begin with reading the file primes.txt, which contains
 just a list of primes listed in a column, using the loadtxt command.
-The file, in our case, is present in ``/home/fossee/primes.txt``.
+The file, in our case, is present in ``/home/fossee/primes.txt``. 
+
+{{{ Navigate to the path in the OS, open the file and show it }}}
 
-#[punch: do we need a slide for showing the path?]
+.. #[punch: do we need a slide for showing the path?]
+
+.. We use the ``cat`` command to see the contents of this file. 
 
-We use the ``cat`` command to see the contents of this file. 
+.. #[punch: should we show the cat command here? seems like a good place
+   to do it] ::
 
-#[punch: should we show the cat command here? seems like a good place
-to do it] ::
+     cat /home/fossee/primes.txt
 
-  cat /home/fossee/primes.txt
+.. #[Nishanth]: A problem for windows users.
+                Should we simply open the file and show them the data
+                so that we can be fine with GNU/Linux ;) and windows?
 
 Now let us read this list into the variable ``primes``.
 ::
@@ -71,6 +69,12 @@
 
   cat /home/fossee/pendulum.txt
 
+.. #[Nishanth]: The first column is L values and second is T values
+                from a simle pelculum experiment.
+                Since you are using the variable names later in the
+                script.
+                Not necessary but can be included also.
+
 Let us, now, read the data into the variable ``pend``. Again, it is
 assumed that the file is in ``/home/fossee/``
 ::
@@ -90,15 +94,21 @@
 
   L, T = loadtxt('/home/fossee/pendulum.txt', unpack=True)
 
+.. #[Nishanth]: It has a sequence of items in which each item contains
+                two values. first is l and second is t
+
 Let us now, print the variables L and T, to see what they contain.
 ::
 
   print L
   print T
 
+.. #[Nishanth]: Stress on ``unpack=True`` ??
+
 Notice, that L and T now contain the first and second columns of data
 from the data file, ``pendulum.txt``, and they are both simple
-sequences.
+sequences. ``unpack=True`` has given us the two columns in to two
+separate sequences instead of one complex sequence. 
 
 {{{ show the slide with loadtxt --- other features }}}
 
@@ -115,7 +125,7 @@
 {{{ switch back to the terminal }}}
 ::
 
-  L, T = loadtxt('/home/fossee/pendulum.txt', unpack``True, delimiter``';')
+  L, T = loadtxt('/home/fossee/pendulum_semicolon.txt', unpack=True, delimiter=';')
 
   print L
 
@@ -134,4 +144,3 @@
 
 Thank you!   
 
-
--- a/lstsq.rst	Thu Sep 23 12:46:52 2010 +0530
+++ b/lstsq.rst	Thu Sep 23 12:51:32 2010 +0530
@@ -1,3 +1,8 @@
+.. Author              : Nishanth
+   Internal Reviewer 1 : Puneeth
+   Internal Reviewer 2 : 
+   External Reviewer   :
+
 Hello friends and welcome to the tutorial on Least Square Fit
 
 {{{ Show the slide containing title }}}
@@ -17,31 +22,14 @@
 pendulum and the second is the corresponding time period of the pendulum.
 
 As we know, the square of time period of a pendulum is directly proportional to
-its length, we shall plot l vs t^2 and verify if the proportionality is linear.
-
-If it is not linear, we shall generate a least square fit line.
-
-{{{ show the slide containing explanation on least square fit }}}
-
-As shown in the slide, we are first going to generate the two matrices tsq and
-A. Then we are going to use the =lstsq= function to find the values of m and c.
-
-To read the input file and parse the data, we are going to loadtxt function.
-Type
-::
+its length, we shall plot l vs t^2 and verify this. 
 
-    data = loadtxt("/home/fossee/pendulum.txt")
-    data
+#[Puneeth:] removed the explanation about loadtxt and unpack
+ option. It's been done in another LO already. simple dependency 
+ should work?
 
-As you can see, data is a sequence containing 90 records. Each record contains
-two values. The first is length and second is time period. But what we need is 
-two sequences. One sequence containing all the length values and one containing
-all the time values.
-
-Hence we have to use the unpack option with loadtxt. It unpacks the data into
- sequences depending on the structure of data.
-
-Type
+To read the input file and parse the data, we are going to use the
+loadtxt function.  Type 
 ::
 
     l, t = loadtxt("/home/fossee/pendulum.txt", unpack=True)
@@ -57,10 +45,20 @@
     tsq = t * t
     plot(l, tsq, 'bo')
 
-
 {{{ switch to the plot window }}}
 
-We can see that there is a visible linear trend.
+#[Puneeth:] Moved explanation of least square fit here. seems more
+apt. 
+
+We can see that there is a visible linear trend, but we do not get a
+straight line connecting them. We shall, therefore, generate a least
+square fit line.
+
+{{{ show the slide containing explanation on least square fit }}}
+
+As shown in the slide, we are first going to generate the two matrices
+tsq and A. Then we are going to use the ``lstsq`` function to find the
+values of m and c.
 
 let us now generate the A matrix with l values.
 We shall first generate a 2 x 90 matrix with the first row as l values and the
@@ -70,20 +68,20 @@
     inter_mat = array((l, ones_like(l)))
     inter_mat
 
-We see that we have intermediate matrix. Now we need the transpose.Type
+We see that we have intermediate matrix. Now we need the transpose. Type
 ::
 
     A = inter_mat.T
     A
 
-Now we have both the matrices A and tsq. We only need to use the =lstsq=
+Now we have both the matrices A and tsq. We only need to use the ``lstsq``
 Type
 ::
 
     result = lstsq(A, tsq)
 
-The result is a sequence of values. The first item is the matrix p or in simple
-words, the values of m and c. Hence, 
+The result is a sequence of values. The first item in this sequence,
+is the matrix p i.e., the values of m and c. Hence, 
 ::
 
     m, c = result[0]
@@ -120,9 +118,5 @@
 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
 
 Hope you have enjoyed and found it useful.
-Thankyou
+Thank you
  
-.. Author              : Nishanth
-   Internal Reviewer 1 : 
-   Internal Reviewer 2 : 
-   External Reviewer   :
--- a/parsing_data.rst	Thu Sep 23 12:46:52 2010 +0530
+++ b/parsing_data.rst	Thu Sep 23 12:51:32 2010 +0530
@@ -1,3 +1,8 @@
+.. Author              : Nishanth
+   Internal Reviewer 1 : 
+   Internal Reviewer 2 : 
+   External Reviewer   :
+
 Hello friends and welcome to the tutorial on Parsing Data
 
 {{{ Show the slide containing title }}}
@@ -6,15 +11,20 @@
 
 In this tutorial, we shall learn
 
- * What is parsing data
+ * What we mean by parsing data
  * the string operations required for parsing data
  * datatype conversion
 
+#[Puneeth]: Changed a few things, here.  
+
+#[Puneeth]: I don't like the way the term "parsing data" has been used, all
+through the script. See if that can be changed.
+
  Lets us have a look at the problem
 
 {{{ Show the slide containing problem statement. }}}
 
-There is an input file containing huge no.of records. Each record corresponds
+There is an input file containing huge no. of records. Each record corresponds
 to a student.
 
 {{{ show the slide explaining record structure }}}
@@ -28,16 +38,22 @@
 #[Nishanth]: Please note that I am not telling anything about AA since they do
              not know about any if/else yet.
 
+#[Puneeth]: Should we talk pass/fail etc? I think we should make the problem
+ simple and leave out all the columns after total marks. 
 
-So what exactly is parsing data?
+Now what is parsing data.
 
+From the input file, we can see that the data we have is in the form of
+text. Parsing this data is all about reading it and converting it into a form
+which can be used for computations -- in our case, sequence of numbers.
 
-Parsing data is all about reading the data and converting it into a form which
-can be used for computations. In our case, that is numbers.
+#[Puneeth]: should the word tokenizing, be used? Should it be defined before
+ using it?
 
 We can clearly see that the problem involves reading files and tokenizing.
 
-.. #[[Amit:Definition of Tokenizing here.]]
+#[Puneeth]: the sentence above seems kinda redundant. 
+
 Let us learn about tokenizing strings. Let us define a string first. Type
 ::
 
@@ -48,11 +64,11 @@
 
     line.split()
 
-As you can see, we get a list of strings. Which means, when split is called
+As you can see, we get a list of strings. Which means, when ``split`` is called
 without any arguments, it splits on whitespace. In simple words, all the spaces
 are treated as one big space.
 
-split also can split on a string of our choice. This is acheived by passing
+``split`` also can split on a string of our choice. This is acheived by passing
 that as an argument. But first lets define a sample record from the file.
 ::
 
@@ -63,8 +79,8 @@
 We can also observe that an empty string appears in the list since there are
 two semi colons without anything in between.
 
-Hence split splits on whitespace if called without an argument and splits on
-the given argument if it is called with an argument.
+To recap, ``split`` splits on whitespace if called without an argument and
+splits on the given argument if it is called with an argument.
 
 {{{ Pause here and try out the following exercises }}}
 
@@ -76,13 +92,13 @@
 We see that when we split on space, multiple whitespaces are not clubbed as one
 and there is an empty string everytime there are two consecutive spaces.
 
-Now that we know how to split a string, we can split the record and retreive each
-field seperately. But there is one problem. The region code "B" and a "B"
+Now that we know how to split a string, we can split the record and retrieve
+each field seperately. But there is one problem. The region code "B" and a "B"
 surrounded by whitespace are treated as two different regions. We must find a
 way to remove all the whitespace around a string so that "B" and a "B" with
 white spaces are dealt as same.
 
-This is possible by using the =strip= method of strings. Let us define a
+This is possible by using the ``strip`` method of strings. Let us define a
 string by typing
 ::
 
@@ -110,20 +126,21 @@
 white space. The only road block we now have is conversion of string to float.
 
 The splitting and stripping operations are done on a string and their result is
-also a string, hence the marks that we have are still strings and mathematical
-operations on them are not possible. We must convert them into integers or floats
+also a string. hence the marks that we have are still strings and mathematical
+operations are not possible on them. We must convert them into numbers
+(integers or floats), before we can perform mathematical operations on them. 
 
-We shall look at converting strings into floats. We define an float string
-first. Type
+We shall look at converting strings into floats. We define a float string
+first. Type 
 ::
 
     mark_str = "1.25"
-    mark = float(mark_str)
+    mark = int(mark_str)
     type(mark_str)
     type(mark)
 
 We can see that string is converted to float. We can perform mathematical
-operations on it now.
+operations on them now.
 
 {{{ Pause here and try out the following exercises }}}
 
@@ -131,8 +148,6 @@
 
 {{{ continue from paused state }}}
 
-.. #[[Amit:I think there should be some interaction first here about the
-problem before we conclude to talking about the result.]]
 It raises an error since converting a float string into integer directly is
 not possible. It involves an intermediate step of converting to float.
 ::
@@ -143,7 +158,7 @@
     number = int(flt)
     number
 
-Using =int= it is possible to convert float into integers.
+Using ``int`` it is also possible to convert float into integers.
 
 Now that we have all the machinery required to parse the file, let us solve the
 problem. We first read the file line by line and parse each record. We see if
@@ -162,7 +177,7 @@
 
         if region_code == "AA":
             math_marks_B.append(math_mark)
-.. #[[Amit:This intutively does not seem to be what you wanted]]
+
 
 Now we have all the maths marks of region "B" in the list math_marks_B.
 To get the mean, we just have to sum the marks and divide by the length.
@@ -179,7 +194,6 @@
  * how to tokenize a string using various delimiters
  * how to get rid of extra white space around
  * how to convert from one type to another
-.. #[[Amit:one datatype to another may be better.]]
  * how to parse input data and perform computations on it
 
 {{{ Show the "sponsored by FOSSEE" slide }}}
@@ -188,9 +202,5 @@
 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
 
 Hope you have enjoyed and found it useful.
-Thankyou
+Thank you
  
-.. Author              : Nishanth
-   Internal Reviewer 1 : Amit Sethi 
-   Internal Reviewer 2 : 
-   External Reviewer   :
--- a/progress.org	Thu Sep 23 12:46:52 2010 +0530
+++ b/progress.org	Thu Sep 23 12:51:32 2010 +0530
@@ -8,13 +8,13 @@
 | 1.7 LO: | additional features of IPython         |     2 | Nishanth | Amit (Pending)      | Madhu (Pending)     |
 | 1.8 LO: | module level assessment                |     3 | Madhu    |                     |                     |
 |---------+----------------------------------------+-------+----------+---------------------+---------------------|
-| 2.2 LO: | loading data from files                |     3 | Punch    |                     |                     |
+| 2.2 LO: | loading data from files                |     3 | Punch    | Nishanth (Done)     | Anoop (Pending)     |
 | 2.3 LO: | plotting the data                      |     3 | Amit     | Anoop (Pending)     | Punch (Pending)     |
 | 2.4 LO: | other types of plots                   |     3 | Anoop    |                     |                     |
 | 2.5 LO: | module level assessment                |     3 | Nishanth |                     |                     |
 |---------+----------------------------------------+-------+----------+---------------------+---------------------|
 | 3.1 LO: | getting started with lists             |     2 | Amit     | Madhu (Pending)     | Nishanth (Done)     |
-| 3.2 LO: | getting started with =for=             |     2 | Anoop    | Nishanth (Done)     | Amit (Pending)      |
+| 3.2 LO: | getting started with =for=             |     2 | Anoop    | Nishanth (Done)     | Amit (Done)         |
 | 3.3 LO: | getting started with strings           |     2 | Madhu    |                     |                     |
 | 3.4 LO: | getting started with files             |     3 | Punch    |                     |                     |
 | 3.5 LO: | parsing data                           |     3 | Nishanth | Amit (Done)         | Punch (Pending)     |
--- a/using-sage.rst	Thu Sep 23 12:46:52 2010 +0530
+++ b/using-sage.rst	Thu Sep 23 12:51:32 2010 +0530
@@ -22,7 +22,8 @@
 We have our Sage notebook running. In case, you don't have it running,
 start is using the command, ``sage --notebook``.
 
-To find the limit of the function x*sin(1/x), at x=0, we say::
+To find the limit of the function x*sin(1/x), at x=0, we say
+::
 
    lim(x*sin(1/x), x=0)
 
@@ -30,18 +31,21 @@
 
 It is also possible to the limit at a point from one direction. For
 example, let us find the limit of 1/x at x=0, when approaching from
-the positive side.::
+the positive side.
+::
 
     lim(1/x, x=0, dir='above')
 
-To find the limit from the negative side, we say,::
+To find the limit from the negative side, we say,
+::
 
     lim(1/x, x=0, dir='above')   
 
 Let us now see how to differentiate, using Sage. We shall find the
 differential of the expression ``exp(sin(x^2))/x`` w.r.t ``x``. We
 shall first define the expression, and then use the ``diff`` function
-to obtain the differential of the expression.::
+to obtain the differential of the expression.
+::
 
     var('x')
     f = exp(sin(x^2))/x
@@ -50,7 +54,8 @@
 
 We can also obtain the partial differentiation of an expression w.r.t
 one of the variables. Let us differentiate the expression
-``exp(sin(y - x^2))/x`` w.r.t x and y.::
+``exp(sin(y - x^2))/x`` w.r.t x and y.
+::
 
     var('x y')
     f = exp(sin(y - x^2))/x
@@ -62,7 +67,8 @@
 Now, let us look at integration. We shall use the expression obtained
 from the differentiation that we did before, ``diff(f, y)`` ---
 ``e^(sin(-x^2 + y))*cos(-x^2 + y)/x``. The ``integrate`` command is
-used to obtain the integral of an expression or function.::
+used to obtain the integral of an expression or function.
+::
 
     integrate(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y)
 
@@ -70,13 +76,15 @@
 outside the ``sin`` function doesn't change much. 
 
 Now, let us find the value of the integral between the limits 0 and
-pi/2. ::
+pi/2. 
+::
 
     integral(e^(sin(-x^2 + y))*cos(-x^2 + y)/x, y, 0, pi/2)
 
 Let us now see how to obtain the Taylor expansion of an expression
 using sage. Let us obtain the Taylor expansion of ``(x + 1)^n`` up to
-degree 4 about 0.::
+degree 4 about 0.
+::
 
     var('x n')
     taylor((x+1)^n, x, 0, 4)
@@ -93,27 +101,97 @@
 matrix ``matrix([[1,2],[3,4]])`` and v is the vector
 ``vector([1,2])``. 
 
-To solve the equation, ``Ax = v`` we simply say::
+To solve the equation, ``Ax = v`` we simply say
+::
 
     x = solve_right(A, v)
 
-To solve the equation, ``xA = v`` we simply say::
+To solve the equation, ``xA = v`` we simply say
+::
 
     x = solve_left(A, v)
 
 The left and right here, denote the position of ``A``, relative to x. 
 
-
+#[Puneeth]: any suggestions on what more to add?
 
 Now, let us look at Graph Theory in Sage. 
 
-Graph: G = Graph({0:[1,2,3], 2:[4]})
-Directed Graph: DiGraph(dictionary)
-Graph families: graphs. tab
-Invariants: G.chromatic polynomial(), G.is planar()
-Paths: G.shortest path()
-Visualize: G.plot(), G.plot3d()
-Automorphisms: G.automorphism group(), G1.is isomorphic(G2), G1.is subgraph(G2)
+We shall look at some ways to create graphs and some of the graph
+families available in Sage. 
+
+The simplest way to define an arbitrary graph is to use a dictionary
+of lists. We create a simple graph by
+::
+
+  G = Graph({0:[1,2,3], 2:[4]})
+
+We say 
+::
+
+  G.show()
+
+to view the visualization of the graph. 
+
+Similarly, we can obtain a directed graph using the ``DiGraph``
+function. 
+::
+
+  G = DiGraph({0:[1,2,3], 2:[4]})
+
+
+Sage also provides a lot of graph families which can be viewed by
+typing ``graph.<tab>``. Let us obtain a complete graph with 5 vertices
+and then show the graph. 
+::
+
+  G = graphs.CompleteGraph(5)
+
+  G.show()
+
+
+Sage provides other functions for Number theory and
+Combinatorics. Let's have a glimpse of a few of them.  
+
+
+::
 
-Now let us look at bits and pieces of Number theory, combinatorics, 
+  prime_range(100, 200)
+
+gives primes in the range 100 to 200. 
+
+::
+
+  is_prime(1999) 
+
+checks if 1999 is a prime number or not. 
+
+::
+
+  factor(2001)
+
+gives the factorized form of 2001. 
+
+::
 
+  C = Permutations([1, 2, 3, 4])
+  C.list()
+
+gives the permutations of ``[1, 2, 3, 4]``
+
+::
+
+  C = Combinations([1, 2, 3, 4])
+  C.list()
+
+gives all the combinations of ``[1, 2, 3, 4]``
+  
+That brings us to the end of this session showing various features
+available in Sage. 
+
+{{{ Show summary slide }}}
+
+We have looked at some of the functions available for Linear Algebra,
+Calculus, Graph Theory and Number theory.   
+
+Thank You!