lstsq/questions.rst
changeset 330 efb8ddf26aff
parent 237 6c203780bfbe
equal deleted inserted replaced
329:5c8e88276e1f 330:efb8ddf26aff
     6    a. array([1, 1, 1])
     6    a. array([1, 1, 1])
     7    #. [1, 1, 1]
     7    #. [1, 1, 1]
     8    #. [1.0, 1.0, 1.0]
     8    #. [1.0, 1.0, 1.0]
     9    #. Error
     9    #. Error
    10    
    10    
       
    11    Answer: array([1, 1, 1])
       
    12    
    11  2. What does ones_like([1.2, 3, 4, 5]) produce
    13  2. What does ones_like([1.2, 3, 4, 5]) produce
    12 
    14 
    13    a. [1.2, 3, 4, 5]
    15    a. [1.2, 3, 4, 5]
    14    #. array([1.0, 1.0, 1.0, 1.0])
    16    #. array([1.0, 1.0, 1.0, 1.0])
    15    #. array([1, 1, 1, 1])
    17    #. array([1, 1, 1, 1])
    16    #. array([1.2, 3, 4, 5])
    18    #. array([1.2, 3, 4, 5])
    17 
    19 
       
    20    Answer: array([1.0, 1.0, 1.0, 1.0])
    18 
    21 
       
    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