--- a/lstsq/questions.rst Tue Oct 12 10:36:46 2010 +0530
+++ b/lstsq/questions.rst Tue Oct 12 10:47:28 2010 +0530
@@ -8,6 +8,8 @@
#. [1.0, 1.0, 1.0]
#. Error
+ Answer: array([1, 1, 1])
+
2. What does ones_like([1.2, 3, 4, 5]) produce
a. [1.2, 3, 4, 5]
@@ -15,4 +17,16 @@
#. array([1, 1, 1, 1])
#. array([1.2, 3, 4, 5])
+ Answer: array([1.0, 1.0, 1.0, 1.0])
+ 3. The plot of ``u`` vs ``v`` is a bunch of scattered points that show a
+ linear trend. How do you find the least square fit line of ``u`` vs ``v``.
+
+ Answer::
+
+ A = array(u, ones_like(u)).T
+ result = lstsq(A, v)
+ m, c = result[0]
+
+ lst_line = m * u + c
+
--- a/lstsq/quickref.tex Tue Oct 12 10:36:46 2010 +0530
+++ b/lstsq/quickref.tex Tue Oct 12 10:47:28 2010 +0530
@@ -1,11 +1,15 @@
-Creating a tuple:\\
-{\ex \lstinline| t = (1, "hello", 2.5)|}
+Creating a matrix with all ones:\\
+{\ex \lstinline| o = ones_like(l)|}
-Accessing elements of tuples:\\
-{\ex \lstinline| t[index] Ex: t[2]|}
+Creating the A matrix:\\
+{\ex \lstinline| A = array(l, ones_like(l)).T|}
-Accessing slices of tuples:\\
-{\ex \lstinline| t[start:stop:step]|}
+Computing least square:\\
+{\ex \lstinline| result = lstsq(A, tsq)|}
-Swapping values:\\
-{\ex \lstinline| a, b = b, a|}
+Obtaining the m and c values:\\
+{\ex \lstinline| m, c = result[0]|}
+
+Computing the least square fit line:\\
+{\ex \lstinline| lst_line = m * l + c|}
+
--- a/lstsq/script.rst Tue Oct 12 10:36:46 2010 +0530
+++ b/lstsq/script.rst Tue Oct 12 10:47:28 2010 +0530
@@ -1,11 +1,6 @@
.. Objectives
.. ----------
-.. A - Students and teachers from Science and engineering backgrounds
- B -
- C -
- D -
-
.. Plotting a least square fit line
.. Prerequisites
@@ -13,6 +8,7 @@
.. 1. Basic Plotting
.. 2. Arrays
+.. 3. Loading data from files
.. Author : Nishanth Amuluru
Internal Reviewer :