--- a/advanced-features-functions/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/advanced-features-functions/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -19,6 +19,7 @@
.. Author : Puneeth
Internal Reviewer : Anoop Jacob Thomas<anoop@fossee.in>
External Reviewer :
+ Language Reviewer : Bhanukiran
Checklist OK? : <put date stamp here, if OK> [2010-10-05]
Script
--- a/getting-started-sagenotebook/quickref.tex Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-sagenotebook/quickref.tex Thu Nov 11 17:39:26 2010 +0530
@@ -1,8 +0,0 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
-
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
-
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
--- a/getting-started-sagenotebook/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-sagenotebook/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -14,7 +14,7 @@
.. #. Be able to evaluate cells, create and delete cells, navigate them.
.. #. Be able to make annotations in the worksheet
.. #. Be able to use tab completion.
-.. #. Be able to use code from other languages in the cells.
+.. #. Be able to use code from other languages in the cells.
.. Prerequisites
.. -------------
@@ -30,10 +30,10 @@
Script
------
+{{{ Show the slide containing the title }}}
+
Hello friends. Welcome to this spoken tutorial on Getting started with
-sage and sage notebook.
-
-{{{ Show the slide containing the title }}}
+Sage and Sage notebook.
{{{ Show the slide containing the outline }}}
@@ -57,9 +57,10 @@
We are assuming that you have Sage installed on your computer now. If
not please visit the page
http://sagemath.org/doc/tutorial/introduction.html#installation for
-the tutorial on how to install Sage. Let us move on now.
+the tutorial on how to install Sage.
-On the terminal type::
+
+Let us now learn how to start Sage. On the terminal type::
sage
@@ -81,8 +82,8 @@
{{{ Intentional *cough* *cough* }}}
to use Sage and nothing else! The Sage notebook also provides a
-convenient way of sharing and publishing our work which is very handy
-when we use Sage for research or for teaching.
+convenient way of sharing and publishing our work, which is very handy
+for research and teaching.
However we can also run our own instances of Sage notebook servers on
all the computers we have a local installation of Sage. To start the
@@ -319,5 +320,3 @@
Hope you have enjoyed and found it useful.
Thank you!
-
-
--- a/getting-started-sagenotebook/slides.org Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-sagenotebook/slides.org Thu Nov 11 17:39:26 2010 +0530
@@ -18,7 +18,7 @@
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-#+TITLE: Accessing parts of arrays
+#+TITLE: Getting started -- Sage
#+AUTHOR: FOSSEE
#+EMAIL:
#+DATE:
@@ -30,81 +30,38 @@
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
* Outline
- - Manipulating one and multi dimensional arrays
- - Access and change individual elements
- - Access and change rows and columns
- - Slicing and striding on arrays to access chunks
- - Read images into arrays and manipulations
-* Sample Arrays
- #+begin_src python
- In []: A = array([12, 23, 34, 45, 56])
-
- In []: C = array([[11, 12, 13, 14, 15],
- [21, 22, 23, 24, 25],
- [31, 32, 33, 34, 35],
- [41, 42, 43, 44, 45],
- [51, 52, 53, 54, 55]])
-
- #+end_src
-* Question 1
- Change the last column of ~C~ to zeroes.
-* Solution 1
- #+begin_src python
- In []: C[:, -1] = 0
- #+end_src
-* Question 2
- Change ~A~ to ~[11, 12, 13, 14, 15]~.
-* Solution 2
- #+begin_src python
- In []: A[:] = [11, 12, 13, 14, 15]
- #+end_src
-* squares.png
- #+begin_latex
- \begin{center}
- \includegraphics[scale=0.6]{squares}
- \end{center}
- #+end_latex
-* Question 3
- - obtain ~[22, 23]~ from ~C~.
- - obtain ~[11, 21, 31, 41]~ from ~C~.
- - obtain ~[21, 31, 41, 0]~.
-* Solution 3
- #+begin_src python
- In []: C[1, 1:3]
- In []: C[0:4, 0]
- In []: C[1:5, 0]
- #+end_src
-* Question 4
- Obtain ~[[23, 24], [33, -34]]~ from ~C~
-* Solution 4
- #+begin_src python
- In []: C[1:3, 2:4]
- #+end_src
-* Question 5
- Obtain the square in the center of the image
-* Solution 5
- #+begin_src python
- In []: imshow(I[75:225, 75:225])
- #+end_src
-* Question 6
- Obtain the following
- #+begin_src python
- [[12, 0], [42, 0]]
- [[12, 13, 14], [0, 0, 0]]
- #+end_src
-
-* Solution 6
- #+begin_src python
- In []: C[::3, 1::3]
- In []: C[::4, 1:4]
- #+end_src
+ - Know what Sage and Sage notebook are.
+ - Be able to start a Sage shell or notebook
+ - Be able to start using the notebook
+ - Be able to create new worksheets
+ - Know about the menu options available
+ - Know about the cells in the worksheet
+ - Be able to evaluate cells, create and delete cells, navigate them.
+ - Be able to make annotations in the worksheet
+ - Be able to use tab completion.
+ - Be able to use code from other languages in the cells.
+* What is Sage?
+ - free, open-source mathematical software.
+ - can do a lot of math for you, including, but not limited to
+ + algebra
+ + geometry
+ + cryptography
+ + graph theory
+ - can be used as aid in teaching and research
* Summary
- You should now be able to --
- - Manipulate 1D \& Multi dimensional arrays
- - Access and change individual elements
- - Access and change rows and columns
- - Slice and stride on arrays
- - Read images into arrays and manipulate them.
+ + What is Sage
+ + How to start Sage shell
+ + What is Sage notebook
+ + How to start the Sage notebook
+ + How to create accounts and start using the notebook
+ + How to create new worksheets
+ + The menus available on the notebook
+ + About cells in the worksheet
+ + Methods to evaluate the cell, create new cells, delete the cells
+ and navigate around the cells
+ + To make annotations in the worksheet
+ + Tab completions
+ + And embedding code of other scripting languages in the cells
* Thank you!
#+begin_latex
\begin{block}{}
--- a/getting-started-sagenotebook/slides.tex Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-sagenotebook/slides.tex Thu Nov 11 17:39:26 2010 +0530
@@ -1,95 +1,104 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-11-11 Thu 02:40
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\definecolor{darkgreen}{rgb}{0,0.5,0}
-
-\usepackage{listings}
-\lstset{language=Python,
- basicstyle=\ttfamily\bfseries,
- commentstyle=\color{red}\itshape,
- stringstyle=\color{darkgreen},
- showstringspaces=false,
- keywordstyle=\color{blue}\bfseries}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Getting started -- Sage}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
-\end{frame}
+\frametitle{Outline}
+\label{sec-1}
-\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\begin{itemize}
+\item Know what Sage and Sage notebook are.
+\item Be able to start a Sage shell or notebook
+\item Be able to start using the notebook
+\item Be able to create new worksheets
+\item Know about the menu options available
+\item Know about the cells in the worksheet
+\item Be able to evaluate cells, create and delete cells, navigate them.
+\item Be able to make annotations in the worksheet
+\item Be able to use tab completion.
+\item Be able to use code from other languages in the cells.
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{What is Sage?}
+\label{sec-2}
+
+\begin{itemize}
+\item free, open-source mathematical software.
+\item can do a lot of math for you, including, but not limited to
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{itemize}
+\item algebra
+\item geometry
+\item cryptography
+\item graph theory
+\end{itemize}
+
+\item can be used as aid in teaching and research
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-3}
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\begin{itemize}
+\item What is Sage
+\item How to start Sage shell
+\item What is Sage notebook
+\item How to start the Sage notebook
+\item How to create accounts and start using the notebook
+\item How to create new worksheets
+\item The menus available on the notebook
+\item About cells in the worksheet
+\item Methods to evaluate the cell, create new cells, delete the cells
+ and navigate around the cells
+\item To make annotations in the worksheet
+\item Tab completions
+\item And embedding code of other scripting languages in the cells
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-4}
-\begin{frame}
- \frametitle{Thank you!}
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/getting-started-with-lists/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-with-lists/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -153,7 +153,7 @@
deletes the element at index 1, i.e the second element of the
list, 'eggs'. The other way is removing element by content. Lets say
one wishes to delete 100 from nonempty list the syntax of the command
-should be
+would be
.. #[[Anoop: let x = [1,2,1,3]
now x.remove(x[2])
@@ -178,6 +178,21 @@
thus remove removes the first occurence of the element in the sequence
and leaves others untouched.
+One should remember this that while del removes by index number.
+Remove , removes on the basis of content being passed so if ::
+
+ k = [1,2,1,3]
+ del([k[2])
+
+gives us [1,2,3]. ::
+
+ k.remove(x[2])
+
+will give us [2,1,3]. Since it deletes the first occurence of what is
+returned by x[2] which is 1.
+
+
+
--- a/getting-started-with-symbolics/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-with-symbolics/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -25,66 +25,65 @@
Symbolics with Sage
-------------------
-Hello friends and welcome to the tutorial on symbolics with sage.
+Hello friends and welcome to the tutorial on Symbolics with Sage.
{{{ Show welcome slide }}}
-
-.. #[Madhu: What is this line doing here. I don't see much use of it]
-
During the course of the tutorial we will learn
{{{ Show outline slide }}}
-* Defining symbolic expressions in sage.
+* Defining symbolic expressions in Sage.
* Using built-in constants and functions.
-* Performing Integration, differentiation using sage.
+* Performing Integration, differentiation using Sage.
* Defining matrices.
-* Defining Symbolic functions.
+* Defining symbolic functions.
* Simplifying and solving symbolic expressions and functions.
-We can use Sage for symbolic maths.
+Amongst a lot of other things, Sage can do Symbolic Math and we shall
+start with defining symbolic expressions in Sage.
+
+Hope you have your Sage notebook open. If not, pause the video and
+start you Sage notebook.
On the sage notebook type::
sin(y)
-It raises a name error saying that y is not defined. But in sage we
-can declare y as a symbol using var function.
+It raises a name error saying that ``y`` is not defined. We need to
+declare ``y`` as a symbol. We do it using the ``var`` function.
+::
-
-::
var('y')
Now if you type::
sin(y)
-sage simply returns the expression.
-
+Sage simply returns the expression.
-Thus sage treats sin(y) as a symbolic expression . We can use
-this to do symbolic maths using sage's built-in constants and
-expressions..
+Sage treats ``sin(y)`` as a symbolic expression. We can use this to do
+symbolic maths using Sage's built-in constants and expressions.
-
-So let us try ::
+Let us try out a few examples. ::
var('x,alpha,y,beta')
x^2/alpha^2+y^2/beta^2
+
+We have defined 4 variables, ``x``, ``y``, ``alpha`` and ``beta`` and
+have defined a symbolic expression using them.
-taking another example ::
+Here is an expression in ``theta`` ::
var('theta')
sin(theta)*sin(theta)+cos(theta)*cos(theta)
-Similarly, we can define many algebraic and trigonometric expressions using sage .
-
+Now that you know how to define symbolic expressions in Sage, here is
+an exercise.
-Following is an exercise that you must do.
+{{ show slide showing question 1 }}
-%% %% Define following expressions as symbolic expressions
-in sage?
+%% %% Define following expressions as symbolic expressions in Sage.
1. x^2+y^2
#. y^2-4ax
@@ -93,42 +92,37 @@
The solution is on your screen.
-
-Sage also provides a few built-in constants which are commonly used in mathematics .
-
-example : pi,e,infinity , Function n gives the numerical values of all these constants.
+{{ show slide showing solution 1 }}
-{{{ Type n(pi) n(e) n(oo) On the sage notebook }}}
-
-
-
-If you look into the documentation of function "n" by doing
-
-.. #[Madhu: "documentation of the function "n"?]
+Sage also provides built-in constants which are commonly used in
+mathematics, for instance pi, e, infinity. The function ``n`` gives
+the numerical values of all these constants.
+::
+ n(pi)
+ n(e)
+ n(oo)
+
+If you look into the documentation of function ``n`` by doing
::
n(<Tab>
-You will see what all arguments it takes and what it returns. It will be very
-helpful if you look at the documentation of all functions introduced through
-this script.
-
-
+You will see what all arguments it takes and what it returns. It will
+be very helpful if you look at the documentation of all functions
+introduced in the course of this script.
-Also we can define the no. of digits we wish to use in the numerical
-value . For this we have to pass an argument digits. Type
+Also we can define the number of digits we wish to have in the
+constants. For this we have to pass an argument -- digits. Type
-.. #[Madhu: "no of digits"? Also "We wish to obtain" than "we wish to
- use"?]
::
n(pi, digits = 10)
-Apart from the constants sage also has a lot of builtin functions like
-sin,cos,log,factorial,gamma,exp,arcsin etc ...
-lets try some of them out on the sage notebook.
+Apart from the constants Sage also has a lot of built-in functions
+like ``sin``, ``cos``, ``log``, ``factorial``, ``gamma``, ``exp``,
+``arcsin`` etc ...
-
+Lets try some of them out on the Sage notebook.
::
sin(pi/2)
@@ -137,9 +131,12 @@
log(e,e)
-Following is are exercises that you must do.
+Following are exercises that you must do.
-%% %% Find the values of the following constants upto 6 digits precision
+{{ show slide showing question 2 }}
+
+%% %% Find the values of the following constants upto 6 digits
+ precision
1. pi^2
#. euler_gamma^2
@@ -150,19 +147,18 @@
1. sin(pi/4)
#. ln(23)
-Please, pause the video here. Do the exercises and then continue.
+Please, pause the video here. Do the exercises and then continue.
-The solutions are on your screen.
+The solutions are on your screen
-
+{{ show slide showing solution 2 }}
-Given that we have defined variables like x,y etc .. , We can define
-an arbitrary function with desired name in the following way.::
+Given that we have defined variables like x, y etc., we can define an
+arbitrary function with desired name in the following way.::
var('x')
function('f',x)
-
Here f is the name of the function and x is the independent variable .
Now we can define f(x) to be ::
@@ -174,29 +170,18 @@
We can also define functions that are not continuous but defined
piecewise. Let us define a function which is a parabola between 0
-to 1 and a constant from 1 to 2 . Type the following as given on the
-screen
-
+to 1 and a constant from 1 to 2 . Type the following
::
var('x')
h(x)=x^2
g(x)=1
- f=Piecewise(<Tab>
-{{{ Show the documentation of Piecewise }}}
-
-::
f=Piecewise([[(0,1),h(x)],[(1,2),g(x)]],x)
f
-
-
-
-
-We can also define functions which are series
-
+We can also define functions convergent series and other series.
We first define a function f(n) in the way discussed above.::
@@ -221,11 +206,11 @@
f(n) = (-1)^(n-1)*1/(2*n - 1)
sum(f(n), n, 1, oo)
-
This series converges to pi/4.
+Following are exercises that you must do.
-Following are exercises that you must do.
+{{ show slide showing question 3 }}
%% %% Define the piecewise function.
f(x)=3x+2
@@ -237,14 +222,15 @@
Please, pause the video here. Do the exercise(s) and then continue.
+{{ show slide showing solution 3 }}
+
Moving on let us see how to perform simple calculus operations using Sage
For example lets try an expression first ::
diff(x**2+sin(x),x)
- 2x+cos(x)
-The diff function differentiates an expression or a function. Its
+The diff function differentiates an expression or a function. It's
first argument is expression or function and second argument is the
independent variable.
@@ -256,44 +242,40 @@
To get a higher order differential we need to add an extra third argument
for order ::
- diff(<tab> diff(f(x),x,3)
+ diff(f(x),x,3)
in this case it is 3.
-
Just like differentiation of expression you can also integrate them ::
x = var('x')
s = integral(1/(1 + (tan(x))**2),x)
s
-
-
-Many a times we need to find factors of an expression ,we can use the "factor" function
+Many a times we need to find factors of an expression, we can use the
+"factor" function
::
- factor(<tab>
+
y = (x^100 - x^70)*(cos(x)^2 + cos(x)^2*tan(x)^2)
f = factor(y)
-One can simplify complicated expression ::
+One can simplify complicated expression ::
f.simplify_full()
-This simplifies the expression fully . We can also do simplification
-of just the algebraic part and the trigonometric part ::
+This simplifies the expression fully. We can also do simplification of
+just the algebraic part and the trigonometric part ::
f.simplify_exp()
f.simplify_trig()
-
-
-One can also find roots of an equation by using find_root function::
+One can also find roots of an equation by using ``find_root`` function::
phi = var('phi')
find_root(cos(phi)==sin(phi),0,pi/2)
-Lets substitute this solution into the equation and see we were
+Let's substitute this solution into the equation and see we were
correct ::
var('phi')
@@ -322,18 +304,13 @@
Please, pause the video here. Do the exercises and then continue.
-
Lets us now try some matrix algebra symbolically ::
-
-
var('a,b,c,d')
A=matrix([[a,1,0],[0,b,0],[0,c,d]])
A
Now lets do some of the matrix operations on this matrix
-
-
::
A.det()
A.inverse()
@@ -348,17 +325,15 @@
Please, pause the video here. Do the exercise(s) and then continue.
-
-
{{{ Show the summary slide }}}
-So in this tutorial we learnt how to
-
+That brings us to the end of this tutorial. In this tutorial we learnt
+how to
-* We learnt about defining symbolic expression and functions.
-* Using built-in constants and functions.
-* Using <Tab> to see the documentation of a function.
-* Simple calculus operations .
-* Substituting values in expression using substitute function.
-* Creating symbolic matrices and performing operation on them .
+* define symbolic expression and functions
+* use built-in constants and functions
+* use <Tab> to see the documentation of a function
+* do simple calculus
+* substitute values in expressions using ``substitute`` function
+* create symbolic matrices and perform operations on them
--- a/getting-started-with-symbolics/slides.org Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-with-symbolics/slides.org Thu Nov 11 17:39:26 2010 +0530
@@ -37,14 +37,14 @@
- Defining Symbolic functions.
- Simplifying and solving symbolic expressions and functions.
-* Questions 1
+* Question 1
- Define the following expression as symbolic
expression in sage.
- x^2+y^2
- y^2-4ax
-* Solutions 1
+* Solution 1
#+begin_src python
var('x,y')
x^2+y^2
@@ -52,10 +52,11 @@
var('a,x,y')
y^2-4*a*x
#+end_src python
-* Questions 2
+* Question 2
- Find the values of the following constants upto 6 digits precision
- pi^2
+ - euler_gamma^2
- Find the value of the following.
@@ -63,13 +64,13 @@
- sin(pi/4)
- ln(23)
-* Solutions 2
+* Solution 2
#+begin_src python
n(pi^2,digits=6)
n(sin(pi/4))
n(log(23,e))
#+end_src python
-* Question 2
+* Question 3
- Define the piecewise function.
f(x)=3x+2
when x is in the closed interval 0 to 4.
@@ -78,7 +79,7 @@
- Sum of 1/(n^2-1) where n ranges from 1 to infinity.
-* Solution Q1
+* Solution 3
#+begin_src python
var('x')
h(x)=3*x+2
@@ -86,18 +87,18 @@
f=Piecewise([[(0,4),h(x)],[(4,6),g(x)]],x)
f
#+end_src python
-* Solution Q2
+
#+begin_src python
var('n')
f=1/(n^2-1)
sum(f(n), n, 1, oo)
#+end_src python
-
-* Questions 3
+* Question 4
- Differentiate the following.
- - x^5*log(x^7) , degree=4
+ - sin(x^3)+log(3x), to the second order
+ - x^5*log(x^7), to the fourth order
- Integrate the given expression
@@ -107,7 +108,7 @@
- cos(x^2)-log(x)=0
- Does the equation have a root between 1,2.
-* Solutions 3
+* Solution 4
#+begin_src python
var('x')
f(x)= x^5*log(x^7)
@@ -121,12 +122,12 @@
find_root(f(x)==0,1,2)
#+end_src
-* Question 4
+* Question 5
- Find the determinant and inverse of :
A=[[x,0,1][y,1,0][z,0,y]]
-* Solution 4
+* Solution 5
#+begin_src python
var('x,y,z')
A=matrix([[x,0,1],[y,1,0],[z,0,y]])
@@ -134,19 +135,12 @@
A.inverse()
#+end_src
* Summary
- - We learnt about defining symbolic
- expression and functions.
- - Using built-in constants and functions.
- - Using <Tab> to see the documentation of a
- function.
-
-* Summary
- - Simple calculus operations .
- - Substituting values in expression
- using substitute function.
- - Creating symbolic matrices and
- performing operation on them .
-
+ - We learnt about defining symbolic expression and functions.
+ - Using built-in constants and functions.
+ - Using <Tab> to see the documentation of a function.
+ - Simple calculus operations .
+ - Substituting values in expression using substitute function.
+ - Creating symbolic matrices and performing operation on them .
* Thank you!
#+begin_latex
\begin{block}{}
--- a/getting-started-with-symbolics/slides.tex Thu Nov 11 03:09:49 2010 +0530
+++ b/getting-started-with-symbolics/slides.tex Thu Nov 11 17:39:26 2010 +0530
@@ -1,4 +1,4 @@
-% Created 2010-11-10 Wed 17:18
+% Created 2010-11-11 Thu 02:03
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
@@ -8,7 +8,6 @@
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
-\usepackage{t1enc}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
@@ -55,7 +54,7 @@
\end{itemize}
\end{frame}
\begin{frame}
-\frametitle{Questions 1}
+\frametitle{Question 1}
\label{sec-2}
\begin{itemize}
@@ -72,28 +71,34 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solutions 1}
+\frametitle{Solution 1}
\label{sec-3}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
var('x,y')
x^2+y^2
var('a,x,y')
y^2-4*a*x
-\end{verbatim}
+\end{lstlisting}
\end{frame}
\begin{frame}
-\frametitle{Questions 2}
+\frametitle{Question 2}
\label{sec-4}
+
\begin{itemize}
\item Find the values of the following constants upto 6 digits precision
\begin{itemize}
\item pi$^2$
+\item euler$_{\mathrm{gamma}}$$^2$
\end{itemize}
+\end{itemize}
+
+\begin{itemize}
\item Find the value of the following.
\begin{itemize}
@@ -104,17 +109,18 @@
\end{itemize}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solutions 2}
+\frametitle{Solution 2}
\label{sec-5}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
n(pi^2,digits=6)
n(sin(pi/4))
n(log(23,e))
-\end{verbatim}
+\end{lstlisting}
\end{frame}
\begin{frame}
-\frametitle{Question 2}
+\frametitle{Question 3}
\label{sec-6}
\begin{itemize}
@@ -127,37 +133,35 @@
\end{itemize}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solution Q1}
+\frametitle{Solution 3}
\label{sec-7}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
var('x')
h(x)=3*x+2
g(x)= 4*x^2
f=Piecewise([[(0,4),h(x)],[(4,6),g(x)]],x)
f
-\end{verbatim}
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Solution Q2}
-\label{sec-8}
+\end{lstlisting}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
var('n')
f=1/(n^2-1)
sum(f(n), n, 1, oo)
-\end{verbatim}
-
+\end{lstlisting}
\end{frame}
\begin{frame}
-\frametitle{Questions 3}
-\label{sec-9}
+\frametitle{Question 4}
+\label{sec-8}
\begin{itemize}
\item Differentiate the following.
\begin{itemize}
-\item x$^5$*log(x$^7$) , degree=4
+\item sin(x$^3$)+log(3x), to the second order
+\item x$^5$*log(x$^7$), to the fourth order
\end{itemize}
\item Integrate the given expression
@@ -176,10 +180,11 @@
\end{itemize}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solutions 3}
-\label{sec-10}
+\frametitle{Solution 4}
+\label{sec-9}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
var('x')
f(x)= x^5*log(x^7)
diff(f(x),x,5)
@@ -190,11 +195,11 @@
var('x')
f=cos(x^2)-log(x)
find_root(f(x)==0,1,2)
-\end{verbatim}
+\end{lstlisting}
\end{frame}
\begin{frame}
-\frametitle{Question 4}
-\label{sec-11}
+\frametitle{Question 5}
+\label{sec-10}
\begin{itemize}
\item Find the determinant and inverse of :
@@ -203,45 +208,33 @@
\end{itemize}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solution 4}
-\label{sec-12}
+\frametitle{Solution 5}
+\label{sec-11}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
var('x,y,z')
A=matrix([[x,0,1],[y,1,0],[z,0,y]])
A.det()
A.inverse()
-\end{verbatim}
+\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Summary}
-\label{sec-13}
+\label{sec-12}
\begin{itemize}
-\item We learnt about defining symbolic
- expression and functions.
+\item We learnt about defining symbolic expression and functions.
\item Using built-in constants and functions.
-\item Using <Tab> to see the documentation of a
- function.
-\end{itemize}
-
-
-\end{frame}
-\begin{frame}
-\frametitle{Summary}
-\label{sec-14}
-
-\begin{itemize}
+\item Using <Tab> to see the documentation of a function.
\item Simple calculus operations .
-\item Substituting values in expression
- using substitute function.
-\item Creating symbolic matrices and
- performing operation on them .
+\item Substituting values in expression using substitute function.
+\item Creating symbolic matrices and performing operation on them .
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Thank you!}
-\label{sec-15}
+\label{sec-13}
\begin{block}{}
\begin{center}
--- a/loops/questions.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/loops/questions.rst Thu Nov 11 17:39:26 2010 +0530
@@ -15,9 +15,10 @@
#. tuples
#. all of the above
-.. I was not sure of how to frame this question. Can someone fix it?
+ Answer: all of the above
- Answer: all of the above
+.. I was not sure of how to frame this question. Can someone fix it?
+.. #[bhanu: it works for every `sequence` or an iterator for that matter right?]
#. ``x = range(20)``. What is x?
@@ -85,7 +86,7 @@
Answer: Nothing is printed
-.. #[[Anoop: I think more questions on while loop has to be added as
+.. #[[Anoop: I think more questions on while loop have to be added as
for loop was already covered in another LO, these questions can be
kept, but it will good if we add few more on while loop]]
@@ -95,4 +96,7 @@
1. A number is called Armstrong number if the sum of cubes of its digits is
equal to the number itself. Find all the three digit Armstrong numbers.
-.. #[[Anoop: Add one more question]]
+2. Collatz sequence - Given a number ``n``, multiply by 3 and add 1 to
+ it, if it is odd, otherwise divide it by two. With whatever ``n``
+ we start with, we finally end with the sequence 4, 2, 1. Write a
+ program to print this, given some number ``n``.
--- a/loops/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/loops/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -19,6 +19,7 @@
.. Author : Puneeth
Internal Reviewer : Anoop Jacob Thomas<anoop@fossee.in>
External Reviewer :
+ Langauge Reviewer : Bhanukiran
Checklist OK? : <put date stamp here, if OK> [2010-10-05]
Script
--- a/manipulating-strings/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/manipulating-strings/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -19,7 +19,8 @@
.. Author : Puneeth
Internal Reviewer : Amit
External Reviewer :
- Checklist OK? : <put date stamp here, if OK> [2010-10-05]
+ Language Reviewer : Bhanukiran
+ Checklist OK? : <08-11-2010, Anand, OK> [2010-10-05]
Script
------
@@ -90,8 +91,8 @@
s[1:-1]
-gives the a substring of s, without the first and the last
-characters.
+gives the substring of s, without the first and the last
+characters of s.
::
--- a/progress.org Thu Nov 11 03:09:49 2010 +0530
+++ b/progress.org Thu Nov 11 17:39:26 2010 +0530
@@ -27,10 +27,10 @@
| 4.4 LO: | Least square fit | 2 | Nishanth | Punch (Done) | |
| 4.5 LO: | Assessment | 3 | Punch | | |
|---------+----------------------------------------+-------+----------+-----------------+-----------|
-| 5.1 LO: | getting started with sage notebook | 3 | Madhu | | |
-| 5.2 LO: | getting started with symbolics | 3 | Amit | Pending | |
+| 5.1 LO: | getting started with sage notebook | 3 | Madhu | Punch (Done) | |
+| 5.2 LO: | getting started with symbolics | 3 | Amit | Punch (Done) | |
| 5.3 LO: | using Sage | 4 | Punch | Anoop (Done) | |
-| 5.4 LO: | using sage to teach | 3 | Nishanth | | |
+| 5.4 LO: | using sage to teach | 3 | Nishanth | Punch (Done) | |
| 5.5 LO: | Assessment | 3 | Anoop | | |
|---------+----------------------------------------+-------+----------+-----------------+-----------|
| 6.1 LO: | basic datatypes & operators | 4 | Amit | Punch (Done) | |
@@ -46,7 +46,7 @@
| 7.5 LO: | sets | 2 | Nishanth | Punch (Done) | |
| 7.6 LO: | Assessment | 3 | Amit | | |
|---------+----------------------------------------+-------+----------+-----------------+-----------|
-| 8.1 LO: | getting started with functions | 3 | Anoop | Pending | |
+| 8.1 LO: | getting started with functions | 3 | Anoop | Punch (Done) | |
| 8.2 LO: | advanced features of functions | 3 | Punch | Anoop (Done) | |
| 8.3 LO: | using python modules | 3 | Anoop | Punch (Done) | |
| 8.4 LO: | writing python scripts | 2 | Nishanth | | |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/statistics/football.txt Thu Nov 11 17:39:26 2010 +0530
@@ -0,0 +1,8 @@
+Cristiano Ronaldo, 86 ,67
+latan Ibrahimovic, 34 , 65
+Lionel Messi , 45 , 41
+Samuel Eto’o , 23 , 24
+Kaka , 43 , 45
+Frank Lampard , 65 ,34
+
+
--- a/statistics/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/statistics/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -13,6 +13,8 @@
.. Getting started with IPython
.. Loading Data from files
.. Getting started with Lists
+.. Accessing Pieces of Arrays
+
.. Author : Amit Sethi
Internal Reviewer : Puneeth
@@ -28,8 +30,12 @@
{{{ Show the slide containing the outline slide }}}
In this tutorial, we shall learn
- * Doing simple statistical operations in Python
- * Applying these to real world problems
+ * Doing statistical operations in Python
+ * Summing set of numbers
+ * Finding there mean
+ * Finding there Median
+ * Finding there Standard Deviation
+
.. #[punch: since loadtxt is anyway a pre-req, I would recommend you
@@ -45,88 +51,13 @@
.. smaller data-set or something. Using lists doesn't seem natural.]
-We will first start with the most necessary statistical operation i.e
-finding mean.
-
-We have a list of ages of a random group of people ::
-
- age_list = [4,45,23,34,34,38,65,42,32,7]
-
-One way of getting the mean could be getting sum of all the ages and
-dividing by the number of people in the group. ::
-
- sum_age_list = sum(age_list)
-
-sum function gives us the sum of the elements. Note that the
-``sum_age_list`` variable is an integer and the number of people or
-length of the list is also an integer. We will need to convert one of
-them to a float before carrying out the division. ::
-
- mean_using_sum = float(sum_age_list)/len(age_list)
-
-This obviously gives the mean age but there is a simpler way to do
-this in Python - using the mean function::
-
- mean(age_list)
-
-Mean can be used in more ways in case of 2 dimensional lists. Take a
-two dimensional list ::
-
- two_dimension=[[1,5,6,8],[1,3,4,5]]
-
-The mean function by default gives the mean of the flattened sequence.
-A Flattened sequence means a list obtained by concatenating all the
-smaller lists into a large long list. In this case, the list obtained
-by writing the two lists one after the other. ::
-
- mean(two_dimension)
- flattened_seq=[1,5,6,8,1,3,4,5]
- mean(flattened_seq)
-
-As you can see both the results are same. ``mean`` function can also
-give us the mean of each column, or the mean of corresponding elements
-in the smaller lists. ::
-
- mean(two_dimension, 0)
- array([ 1. , 4. , 5. , 6.5])
-
-we pass an extra argument 0 in that case.
-
-If we use an argument 1, we obtain the mean along the rows. ::
-
- mean(two_dimension, 1)
- array([ 5. , 3.25])
-
-We can see more option of mean using ::
-
- mean?
-
-Similarly we can calculate median and stanard deviation of a list
-using the functions median and std::
-
- median(age_list)
- std(age_list)
-
-Median and std can also be calculated for two dimensional arrays along
-columns and rows just like mean.
-
-For example ::
-
- median(two_dimension, 0)
- std(two_dimension, 1)
-
-This gives us the median along the colums and standard devition along
-the rows.
-
-Now lets apply this to a real world example
-
-We will a data file that is at the a path ``/home/fossee/sslc2.txt``.
-It contains record of students and their performance in one of the
-State Secondary Board Examination. It has 180, 000 lines of record. We
-are going to read it and process this data. We can see the content of
-file by double clicking on it. It might take some time to open since
-it is quite a large file. Please don't edit the data. This file has
-a particular structure.
+For this tutorial We will use data file that is at the a path
+``/home/fossee/sslc2.txt``. It contains record of students and their
+performance in one of the State Secondary Board Examination. It has
+180,000 lines of record. We are going to read it and process this
+data. We can see the content of file by double clicking on it. It
+might take some time to open since it is quite a large file. Please
+don't edit the data. This file has a particular structure.
We can do ::
@@ -134,6 +65,9 @@
to check the contents of the file.
+
+{{{ Show the data structure on a slide }}}
+
Each line in the file is a set of 11 fields separated
by semi-colons Consider a sample line from this file.
A;015163;JOSEPH RAJ S;083;042;47;00;72;244;;;
@@ -147,45 +81,97 @@
* Total marks 244
-Now lets try and find the mean of English marks of all students.
-
-For this we do. ::
+Lets try and load this data as an array and then run various function on
+it.
- L=loadtxt('/home/fossee/sslc2.txt',usecols=(3,),delimiter=';')
+To get the data as an array we do. ::
+
+ L=loadtxt('/home/amit/sslc2.txt',usecols=(3,4,5,6,7,),delimiter=';')
L
- mean(L)
+
loadtxt function loads data from an external file.Delimiter specifies
-the kind of character are the fields of data seperated by.
-usecols specifies the columns to be used so (3,). The 'comma' is added
-because usecols is a sequence.
+the kind of character are the fields of data seperated by. usecols
+specifies the columns to be used so (3,4,5,6,7) loads those
+colums. The 'comma' is added because usecols is a sequence.
-To get the median marks. ::
+As we can see L is an array. We can get the shape of this array using::
- median(L)
+ L.shape
+ (185667, 5)
+
+Lets start applying statistics operations on these. We will start with
+the most basic, summing. How do you find the sum of marks of all
+subjects for the first student.
+
+As we know from our knowledge of accessing pieces of arrays. To acess
+the first row we will do ::
-Standard deviation. ::
-
- std(L)
+ L[0,:]
+
+Now to sum this we can say ::
+ totalmarks=sum(L[0,:])
+ totalmarks
-Now lets try and and get the mean for all the subjects ::
+To get the mean we can do ::
+
+ totalmarks/len(L[0,:])
+
+or simply ::
+
+ mean(L[0,:])
- L=loadtxt('/home/fossee/sslc2.txt',usecols=(3,4,5,6,7),delimiter=';')
- mean(L,0)
- array([ 73.55452504, 53.79828941, 62.83342759, 50.69806158, 63.17056881])
+But we have such a large data set calculating one by one the mean of
+each student is impossible. Is there a way to reduce the work.
+
+For this we will look into the documentation of mean by doing::
-As we can see from the result mean(L,0). The resultant sequence
-is the mean marks of all students that gave the exam for the five subjects.
+ mean?
-and ::
-
+As we know L is a two dimensional array. We can calculate the mean
+across each of the axis of the array. The axis of rows is referred by
+number 0 and columns by 1. So to calculate mean accross all colums we
+will pass extra parameter 1 for the axis.::
+
mean(L,1)
-
-is the average accumalative marks of individual students. Clearly, mean(L,0)
-was a row wise calcultaion while mean(L,1) was a column wise calculation.
+L here is the two dimensional array.
+
+Similarly to calculate average marks scored by all the students for each
+subject can be calculated using ::
+
+ mean(L,0)
+
+Next lets now calculate the median of English marks for the all the students
+We can access English marks of all students using ::
+
+ L[:,0]
+
+To get the median we will do ::
+
+ median(L[:,0])
+For all the subjects we can use the same syntax as mean and calculate
+median across all rows using ::
+
+ median(L,0)
+
+
+Similarly to calculate standard deviation for English we can do::
+
+ std(L[:,0])
+
+and for all rows::
+
+ std(L,0)
+
+Following is an exercise that you must do.
+
+%% %% In the given file football.txt at path /home/fossee/football.txt , one column is player name,second is goals at home and third goals away.
+ 1.Find the total goals for each player
+ 2.Mean home and away goals
+ 3.Standard deviation of home and away goals
{{{ Show summary slide }}}
--- a/statistics/slides.org Thu Nov 11 03:09:49 2010 +0530
+++ b/statistics/slides.org Thu Nov 11 17:39:26 2010 +0530
@@ -2,32 +2,73 @@
#+LaTeX_CLASS_OPTIONS: [presentation]
#+BEAMER_FRAME_LEVEL: 1
-#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent}
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
-#+OPTIONS: H:5 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
#+TITLE: Statistics
#+AUTHOR: FOSSEE
-#+DATE: 2010-09-14 Tue
+#+DATE
#+EMAIL: info@fossee.in
-# \author[FOSSEE] {FOSSEE}
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+
+* Outline
+ - Doing statistical operations in Python
+ - Summing set of numbers
+ - Finding there mean
+ - Finding there Median
+ - Finding there Standard Deviation
+
+* Data set
+ - A;015163;JOSEPH RAJ S;083;042;47;00;72;244;;;
-# \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-# \date{}
+ The following are the fields in any given line.
+ - Region Code which is 'A'
+ - Roll Number 015163
+ - Name JOSEPH RAJ S
+ - Marks of 5 subjects: -- English 083 --
+ Hindi 042 -- Maths 47 --
+ Science 35 -- Social 72
+ - Total marks 244
-* Tutorial Plan
-** Doing simple statistical operations in Python
-** Using loadtxt to solve statistics problem
+* Question
+ - In the given file football.txt at path /home/fossee/football.txt ,
+ one column is player name,second is goals at home
+ and third goals away.
+ - Find the total goals for each player
+ - Mean home and away goals
+ - Standard deviation of home and away goals
+
+* Solution
+#+begin_src python
+ L=loadtxt('/home/amit/football.txt',usecols=(1,2),
+ delimiter=',')
+ sum(L,1)
+ mean(L,0)
+ std(L,0)
+#+end_src python
* Summary
-** seq=[1,5,6,8,1,3,4,5]
-** sum(seq)
-** mean(seq)
-** median(seq)
-** std(seq)
+ - sum
+ - mean
+ - median
+ - std
-* Summary
-
-** loadtxt
--- a/statistics/slides.tex Thu Nov 11 03:09:49 2010 +0530
+++ b/statistics/slides.tex Thu Nov 11 17:39:26 2010 +0530
@@ -1,106 +1,122 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-11-11 Thu 01:35
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
-
-\definecolor{darkgreen}{rgb}{0,0.5,0}
-
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{t1enc}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
\usepackage{listings}
-\lstset{language=Python,
- basicstyle=\ttfamily\bfseries,
- commentstyle=\color{red}\itshape,
- stringstyle=\color{darkgreen},
- showstringspaces=false,
- keywordstyle=\color{blue}\bfseries}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
+\title{Statistics}
+\author{FOSSEE}
+\date{11 November 2010}
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date{}
-
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
-\begin{frame}
- \maketitle
-\end{frame}
+\maketitle
-\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+
+
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+
+
\begin{frame}
- \frametitle{Thank you!}
- \begin{block}{}
- \begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
- \end{center}
- \begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
- \end{center}
- \end{block}
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Doing statistical operations in Python
+
+\begin{itemize}
+\item Summing set of numbers
+\item Finding there mean
+\item Finding there Median
+\item Finding there Standard Deviation
+\end{itemize}
+
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Data set}
+\label{sec-2}
+
+\begin{itemize}
+\item A;015163;JOSEPH RAJ S;083;042;47;00;72;244;;;
+\end{itemize}
+
+
+ The following are the fields in any given line.
+\begin{itemize}
+\item Region Code which is `A'
+\item Roll Number 015163
+\item Name JOSEPH RAJ S
+\item Marks of 5 subjects: -- English 083 --
+ Hindi 042 -- Maths 47 --
+ Science 35 -- Social 72
+\item Total marks 244
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Question}
+\label{sec-3}
+
+\begin{itemize}
+\item In the given file football.txt at path /home/fossee/football.txt ,
+ one column is player name,second is goals at home
+ and third goals away.
+
+\begin{itemize}
+\item Find the total goals for each player
+\item Mean home and away goals
+\item Standard deviation of home and away goals
+\end{itemize}
+
+\end{itemize}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution}
+\label{sec-4}
+
+\begin{verbatim}
+L=loadtxt('/home/amit/football.txt',usecols=(1,2),
+ delimiter=',')
+sum(L,1)
+mean(L,0)
+std(L,0)
+\end{verbatim}
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-5}
+
+\begin{itemize}
+\item sum
+\item mean
+\item median
+\item std
+\end{itemize}
\end{frame}
\end{document}
--- a/using-plot-interactively/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/using-plot-interactively/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -21,11 +21,10 @@
Script
-------
-
+{{{ Show the Title Slide }}}
Hello and welcome to the tutorial on creating simple plots using
Python.This tutorial is presented by the Fossee group.
-{{{ Show the Title Slide }}}
I hope you have IPython running on your computer.
@@ -52,13 +51,11 @@
{{{ Slide with Error written on it }}}
-
-
Then you have to install matplotlib and run this command again.
Now type in your ipython shell ::
- In[]: linpace?
+ linpace?
@@ -66,20 +63,20 @@
calculated over the interval start and stop. To illustrate this, lets
do it form 1 to 100 and try 100 points. ::
- In[]: linspace(1,100,100)
+ linspace(1,100,100)
As you can see a sequence of numbers from 1 to 100 appears.
Now lets try 200 points between 0 and 1 you do this by typing ::
- In[]: linspace(0,1,200)
+ linspace(0,1,200)
0 for start , 1 for stop and 200 for no of points. In linspace
the start and stop points can be integers, decimals , or
constants. Let's try and get 100 points between -pi to pi. Type ::
- In[]: p = linspace(-pi,pi,100)
+ p = linspace(-pi,pi,100)
'pi' here is constant defined by pylab. Save this to the variable, p
@@ -87,17 +84,17 @@
If you now ::
- In[]: len(p)
+ len(p)
You will get the no. of points. len function gives the no of elements
of a sequence.
Let's try and plot a cosine curve between -pi and pi using these
-points. Simply type ::
+points. Simply type::
+ plot(p,cos(points))
- In[]: plot(p,cos(points))
Here cos(points) gets the cosine value at every corresponding point to
p.
@@ -106,15 +103,15 @@
We can also save cos(points) to variable cosine and plot it using
plot.::
- In[]: cosine=cos(points)
+ cosine=cos(points)
- In[]: plot(p,cosine)
+ plot(p,cosine)
Now do ::
- In[]: clf()
+ clf()
this will clear the plot.
@@ -124,7 +121,7 @@
plot. ::
- In []: plot(p,sin(p))
+ plot(p,sin(p))
@@ -144,37 +141,57 @@
-{{{ Action corelating with the words }}}
+{{{ Show how to save the file }}}
As you can see I can specify format of file from the dropdown.
-Formats like png ,eps ,pdf, ps are available.
+Formats like png ,eps ,pdf, ps are available.
-Left to the save button is the slider button to specify the margins.
+Left to the save button is the slider button to specify the margins.
-{{{ Action corelating with the words }}}
+{{{ Show how to zoom. Press zoom button and specify region to zoom }}}
Left to this is zoom button to zoom into the plot. Just specify the
region to zoom into.
+
+{{{ Press Move button and move the axes. }}}
+
The button left to it can be used to move the axes of the plot.
-{{{ Action corelating with the words }}}
+{{{ Press Back and Forward Button }}}
The next two buttons with a left and right arrow icons change the state of the
plot and take it to the previous state it was in. It more or less acts like a
back and forward button in the browser.
-{{{ Action corelating with the words }}}
+{{{ Press home button }}}
The last one is 'home' referring to the initial plot.
-{{{ Action corelating with the words}}}
+
+
+
+Following is an exercise that you must do.
+
+%% %% Plot (sin(x)*sin(x))/x .
+ 1. Save the plot by the sinsquarebyx.pdf in pdf format.
+ 2. Zoom and find the maxima.
+
+ 3. Bring it back to initial position.
+
+
+Please, pause the video here. Do the exercise and then continue.
+
+
+
+
+
+
{{{ Summary Slide }}}
-
In this tutorial we have looked at
1. Starting Ipython with pylab
@@ -190,10 +207,7 @@
5. Using the UI of plot for studying it better . Using functionalities like save , zoom and moving the plots on x and y axis
-
-
-
-{{{ Show the "sponsored by FOSSEE" slide }}}
+ {{{ Show the "sponsored by FOSSEE" slide }}}
--- a/using-plot-interactively/slides.org Thu Nov 11 03:09:49 2010 +0530
+++ b/using-plot-interactively/slides.org Thu Nov 11 17:39:26 2010 +0530
@@ -2,36 +2,75 @@
#+LaTeX_CLASS_OPTIONS: [presentation]
#+BEAMER_FRAME_LEVEL: 1
-#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent}
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
-#+OPTIONS: H:5 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
-#+TITLE: Plotting Data
-#+AUTHOR: FOSSEE
-#+DATE: 2010-09-14 Tue
-#+EMAIL: info@fossee.in
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-# \author[FOSSEE] {FOSSEE}
+#+TITLE: Using Plot Interactively
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
-# \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-# \date{}
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
-* Tutorial Plan
-** Creating a simple plot
-** Use the buttons on window to study the plot
+* Outline
+ - Plot a simple mathemaical function.
+ - Using the User Interface of plot figure.
* Error if Ipython not installed
** `ERROR: matplotlib could NOT be imported! Starting normal IPython.`
+
* Plot UI
-
-* Summary
+#+begin_latex
+ \includegraphics[height=0.12in, interpolate=true]{buttons}
+#+end_latex
+ - Save
+ - Zoom
+ - Move axis
+ - Back and Forward Button
+ - Home
-** Start Ipython with pylab
-** Using linspace
-** Finding length of sequnces using len.
-** Plotting mathematical functions using plot.
-** Clearing drawing area using clf
-** Using the UI of plot
+
+* Summary
+ - Plotting mathematical functions using plot.
+ - Using the UI of plot
+ - Save
+ - Zoom
+ - Move axis
+ - Back and Forward Button
+ - Home
+
+* Thank You!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/using-plot-interactively/slides.tex Thu Nov 11 03:09:49 2010 +0530
+++ b/using-plot-interactively/slides.tex Thu Nov 11 17:39:26 2010 +0530
@@ -1,35 +1,52 @@
-% Created 2010-10-20 Wed 21:57
+% Created 2010-11-11 Thu 13:15
\documentclass[presentation]{beamer}
-\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
+\usepackage{t1enc}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
-
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\title{Plotting Data }
+\title{Using Plot Interactively}
\author{FOSSEE}
-\date{2010-09-14 Tue}
+\date{}
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
\maketitle
-\begin{frame}
-\frametitle{Tutorial Plan}
-\label{sec-1}
-\begin{itemize}
+
+
+
+
+
+
-\item Creating a simple plot\\
-\label{sec-1.1}%
-\item Use the buttons on window to study the plot\\
-\label{sec-1.2}%
-\end{itemize} % ends low level
+
+\begin{frame}
+\frametitle{Outline}
+\label{sec-1}
+
+ How to plot a simple mathematical function.
+ Using the User Interface of plot figure.
\end{frame}
\begin{frame}
\frametitle{Error if Ipython not installed}
@@ -37,35 +54,46 @@
\begin{itemize}
\item `ERROR: matplotlib could NOT be imported! Starting normal IPython.`\\
-\label{sec-2.1}%
+\label{sec-2_1}%
\end{itemize} % ends low level
\end{frame}
\begin{frame}
\frametitle{Plot UI}
\label{sec-3}
+
+ \includegraphics[height=0.12in, interpolate=true]{buttons}
+\begin{itemize}
+\item Save
+\item Zoom
+\item Move axis
+\item Back and Forward Button
+\item Home
+\end{itemize}
+
+
+
+\end{frame}
\begin{frame}
- \begin{center}
- \includegraphics[height=1.0in,width=4.2in]{buttons.png}
- \end{center}
-\end{frame}
-
\frametitle{Summary}
\label{sec-4}
+
\begin{itemize}
+\item Plotting mathematical functions using plot.
+ \includegraphics[height=0.12in, interpolate=true]{buttons}
+\item Using the UI of plot
-\item Start Ipython with pylab\\
-\label{sec-4.1}%
-\item Using linspace\\
-\label{sec-4.2}%
-\item Finding length of sequnces using len.\\
-\label{sec-4.3}%
-\item Plotting mathematical functions using plot.\\
-\label{sec-4.4}%
-\item Clearing drawing area using clf\\
-\label{sec-4.5}%
-\item Using the UI of plot\\
-\label{sec-4.6}%
-\end{itemize} % ends low level
+\begin{itemize}
+\item Save
+\item Zoom
+\item Move axis
+\item Back and Forward Button
+\item Home
+\end{itemize}
+
+\end{itemize}
+
+
+
\end{frame}
\end{document}
--- a/using_sage_to_teach/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/using_sage_to_teach/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -19,9 +19,9 @@
Script
------
-Hello friends and welcome to the tutorial on "Using SAGE to teach"
+{{{ Show the slide containing title }}}
-{{{ Show the slide containing title }}}
+Hello friends and welcome to the tutorial on Using SAGE to teach
{{{ Show the slide containing the outline slide }}}
@@ -41,14 +41,14 @@
::
t = var('t')
- p1 = plot( e^(-t/2) * sin(2*t), (t, 0, 15))
+ p1 = plot(e^(-t/2) * sin(2*t), (t, 0, 15))
show(p1)
Now if we want to reduce the damping factor even more, we would be using
e^(-t/3). We can observe that every time we have to change, all we do is change
something very small and re evaluate the cell.
-This process can be automated using the ``@interact`` feature of SAGE.
+This process can be simplified, using the ``@interact`` feature of SAGE.
::
@@ -141,10 +141,10 @@
in the top right, we can see a button called ``publish``. Click on that and we
get a confirmation page with an option for re publishing.
-For now lets forget that opion and simply publish by cliking ``yes``. The
+For now lets forget that option and simply publish by clicking ``yes``. The
worksheet is now published.
-Now lets signout and go to the sage notebook home. We see link to browse
+Now lets sign out and go to the sage notebook home. We see link to browse
published worksheets. Lets click on it and we can see the worksheet. This does
not require login and anyone can view the worksheet.
@@ -173,9 +173,8 @@
{{{ Show the "sponsored by FOSSEE" slide }}}
-#[Nishanth]: Will add this line after all of us fix on one.
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!
--- a/writing_python_scripts/questions.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/writing_python_scripts/questions.rst Thu Nov 11 17:39:26 2010 +0530
@@ -118,3 +118,29 @@
Hello World
Hello Test
+ 7. Say, we wish to use the ``pi`` value from the ``math`` module in
+ the standard library. How do we import it?
+
+ Answer: from math import pi OR import math.pi OR
+ import math.pi as pi
+
+
+ 8. A module should contain only functions, True or False?
+
+ Answer: False.
+
+
+Larger Questions
+----------------
+
+1. Look at the python documentation (from the web) and learn how to
+ make a folder containing some python files into a module.
+
+ Answer: Add a file named __init__.py
+
+2. We know that ``sys.path`` has the paths in which Python checks for
+ a module, when it is imported. Suppose you have a package ``utils``
+ in some location on your disk, which is not on the python path, how
+ will you import it?
+
+ Answer: Append that path to the ``sys.path`` variable.
--- a/writing_python_scripts/script.rst Thu Nov 11 03:09:49 2010 +0530
+++ b/writing_python_scripts/script.rst Thu Nov 11 17:39:26 2010 +0530
@@ -19,19 +19,19 @@
Script
------
-Hello friends and welcome to the tutorial on "Writing Python scripts"
+{{{ Show the slide containing title }}}
-{{{ Show the slide containing title }}}
+Hello friends and welcome to the tutorial on "Writing Python scripts"
{{{ Show the slide containing the outline slide }}}
In this tutorial, we shall learn
- * How write Python scripts
+ * How to write Python scripts
Often we will have to reuse the code that we haave written. We do that by
writing functions. Functions are bundled into packages and are imported as and
-required in the script.
+when required in other scripts.
Let us first write a function that computes the gcd of two numbers and save it
in a script.
@@ -58,16 +58,16 @@
else:
print "The GCD function is wrong"
-Let us save the file as script.py in /home/fossee/gcd_script.py
+Let us save the file as script.py in ``/home/fossee/gcd_script.py``
-We shall run the script by doing
+We shall run the script by typing
::
$ python /home/fossee/gcd_script.py
We can see that the script is executed and everything is fine.
-What if we want to use the gcd function in some of our later scripts. This
+What if we want to use the gcd function in some of our other scripts. This
is also possible since every python file can be used as a module.
But first, we shall understand what happens when you import a module.
@@ -81,13 +81,14 @@
This is a list of locations where python searches for a module when it
encounters an import statement.
-hence when we just did =import sys=, python searches for a file named sys.py or
-a folder named sys in all these locations one by one, until it finds one.
+Hence, when we just did ``import sys``, python searches for a file
+named sys.py or a folder named sys in all these locations one by one,
+until it finds one.
We can place our script in any one of these locations and can import it.
-The first item in the list is an empty string which means the current working
-directory is also searched.
+The first item in the list is an empty string which means the current
+working directory is also searched.
Alternatively, we can also import the module if we are working in same
directory where the script exists.
@@ -103,9 +104,9 @@
But we want the test code to be executed only when the file is run as a python
script and not when it is imported.
-This is possible by using =__name__= variable.
+This is possible by using ``__name__`` variable.
-First we shall look at how to use the idiom and then understand how it works.
+First, we shall look at how to use the idiom and then understand how it works.
Go to the file and add
::
@@ -128,11 +129,12 @@
We see that now the test code is not executed.
-The __name__ variable is local to every module and it is equal to __main__ only
-when the file is run as a script.
+The ``__name__`` variable is local to every module and it is equal to
+``__main__`` only when the file is run as a script.
-hence all the code that goes after __name__ == "__main__" is executed only when
-the file is run as a python script.
+Hence, all the code that goes in to the if block, ``if __name__ ==
+"__main__":`` is executed only when the file is run as a python
+script.
{{{ Show summary slide }}}
@@ -145,9 +147,8 @@
{{{ Show the "sponsored by FOSSEE" slide }}}
-#[Nishanth]: Will add this line after all of us fix on one.
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!