author | Nishanth <nishanth@fossee.in> |
Tue, 12 Oct 2010 11:44:33 +0530 | |
changeset 335 | d5248a15274c |
parent 330 | efb8ddf26aff |
permissions | -rw-r--r-- |
237
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
1 |
Objective Questions |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
2 |
------------------- |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
3 |
|
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
4 |
1. What does ones_like([1, 2, 3]) produce |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
5 |
|
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
6 |
a. array([1, 1, 1]) |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
7 |
#. [1, 1, 1] |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
8 |
#. [1.0, 1.0, 1.0] |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
9 |
#. Error |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
10 |
|
330 | 11 |
Answer: array([1, 1, 1]) |
12 |
||
237
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
13 |
2. What does ones_like([1.2, 3, 4, 5]) produce |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
14 |
|
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
15 |
a. [1.2, 3, 4, 5] |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
16 |
#. array([1.0, 1.0, 1.0, 1.0]) |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
17 |
#. array([1, 1, 1, 1]) |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
18 |
#. array([1.2, 3, 4, 5]) |
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
19 |
|
330 | 20 |
Answer: array([1.0, 1.0, 1.0, 1.0]) |
237
6c203780bfbe
Converted lstsq to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
21 |
|
330 | 22 |
3. The plot of ``u`` vs ``v`` is a bunch of scattered points that show a |
23 |
linear trend. How do you find the least square fit line of ``u`` vs ``v``. |
|
24 |
||
25 |
Answer:: |
|
26 |
||
27 |
A = array(u, ones_like(u)).T |
|
28 |
result = lstsq(A, v) |
|
29 |
m, c = result[0] |
|
30 |
||
31 |
lst_line = m * u + c |
|
32 |