[Numpy-discussion] linear_algebra2

Colin J. Williams cjw at sympatico.ca
Sat Nov 8 14:21:05 EST 2003


Here are some suggested changes to the linear_least_squares function.

Colin W.

Lines 571 ownward are:
    resids = num.array([],type=t)
    if one_eq:
        x = copy.copy(num.ravel(bstar)[:n])
        if (results['rank']==n) and (m>n):
            resids = num.array([num.sum((num.ravel(bstar)[n:])**2)])
    else:
        x = copy.copy(num.transpose(bstar)[:n,:])
        if (results['rank']==n) and (m>n):
            resids = copy.copy(num.sum((num.transpose(bstar)[n:,:])**2))
    resids= bstar       
    return x,resids,results['rank'],copy.copy(s[:min(n,m)])

Line 571 should probably read:
    resids = None
as no information is available if n >= m, probably the common case.

Line 580 should be deleted, as it returns misleading information.

For the n > m cases it would probably be good to return:
     (b - a * x).var(0), where the function var(0) delivers a row vector 
containing the column variances.





More information about the NumPy-Discussion mailing list