[Numpy-discussion] Efficient orthogonalisation with scipy/numpy

Robert Kern robert.kern at gmail.com
Tue Jan 19 15:22:30 EST 2010


On Tue, Jan 19, 2010 at 14:12, Gael Varoquaux
<gael.varoquaux at normalesup.org> wrote:
> Hi there,
>
> Forgive me for turning to the mailing list to do my homework. I am
> currently optimizing a code, and it turns out that the main bottleneck is
> the orthogonalisation of a vector 'y' to a set of vectors 'confounds',
> that I am currently doing with the following code:
>
> y = y - np.dot(confounds.T, linalg.lstsq(confounds.T, y)[0])
>
> with np = numpy and linalg = scipy.linalg where scipy calls ATLAS.

For clarification, are you trying to find the components of the y
vectors that are perpendicular to the space spanned by the 10
orthonormal vectors in confounds?

> Most of the time is spent in linalg.lstsq. The length of the vectors is
> 810, and there are about 10 confounds.

Exactly what are the shapes? y.shape = (810, N); confounds.shape = (810, 10)?

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list