lstsq/quickref.tex
changeset 330 efb8ddf26aff
parent 237 6c203780bfbe
equal deleted inserted replaced
329:5c8e88276e1f 330:efb8ddf26aff
     1 Creating a tuple:\\
     1 Creating a matrix with all ones:\\
     2 {\ex \lstinline|    t = (1, "hello", 2.5)|}
     2 {\ex \lstinline|    o = ones_like(l)|}
     3 
     3 
     4 Accessing elements of tuples:\\
     4 Creating the A matrix:\\
     5 {\ex \lstinline|    t[index] Ex: t[2]|}
     5 {\ex \lstinline|    A = array(l, ones_like(l)).T|}
     6 
     6 
     7 Accessing slices of tuples:\\
     7 Computing least square:\\
     8 {\ex \lstinline|    t[start:stop:step]|}
     8 {\ex \lstinline|    result = lstsq(A, tsq)|}
     9 
     9 
    10 Swapping values:\\
    10 Obtaining the m and c values:\\
    11 {\ex \lstinline|    a, b = b, a|}
    11 {\ex \lstinline|    m, c = result[0]|}
       
    12 
       
    13 Computing the least square fit line:\\
       
    14 {\ex \lstinline|    lst_line = m * l + c|}
       
    15