Re: Similar matrices->similar eigenvectors?

• To: mathgroup at smc.vnet.net
• Subject: [mg80381] Re: Similar matrices->similar eigenvectors?
• From: Ray Koopman <koopman at sfu.ca>
• Date: Mon, 20 Aug 2007 06:05:34 -0400 (EDT)
• References: <fabgkn\$ici\$1@smc.vnet.net>

```u = previous eigenvectors
v = current eigenvectors

v = (r = u.#; If[r[[Ordering[Abs@r,-1][[1]]]]<0,-#,#])& /@ v

will reorient the current eigenvectors to agree with the previous
ones. You're on your own the first time thru. Try u = {{1,...,1}}?

On Aug 20, 12:42 am, Yaroslav Bulatov <yarosla... at gmail.com> wrote:
> In the default implementation of "Eigenvectors", the orientations seem
> arbitrary. Changing the matrix slightly could end up flipping the
> eigenvectors 180 degrees. A simple fix of telling eigenvectors to
> always be on one side of some arbitrary plane doesn't work because it
> will flip eigenvectors that are near-parallel to the plane with small
> changes in the matrix.
>
> I'm trying to make a demo of multi-dimensional scaling, and the result
> is that as I drag the slider, the points flip back and forth
> erratically.
>
> Basically I'd like to get a function g[mat] which returns eigenvectors
> of mat, and is continuous, what is the simplest way of achieving this?
>
> -----------
> distances2points[d_] := (n = Length[d];
>   (*nxn matrix of ones*)j = Table[1, {n, n}];
>   (*centering matrix*)h = IdentityMatrix[n] - j/n;
>   a = -d*d/2;
>   b = h.a.h;
>   (*Eigenvectors are returned with arbitrary orientation,
>   orient them to point in the same halfplane*)
>   orient[v_, orientvec_] := ((*1,1,1,1 halfplane is often ambiguous,
>     use random halfplane*)(*SeedRandom[0];
>     orientvec=RandomReal[{0,1},Length[v]];*)
>     If[Round[v, .1].orientvec > 0, -v, v]);
>   vecs = Eigenvectors[b][[1 ;; 2]];
>   (*vecs=orient[#,b[[1]]]&/@vecs;*)
>   vals = Eigenvalues[b][[1 ;; 2]];
>   Point[Re[#]] & /@ Transpose[vecs*Sqrt[vals]])
> Clear[d1, d2, d3, d4, d5, d6]; limits = {{{d1, 0, "1->2"}, 0,
>    1}, {{d2, 0, "1->3"}, 0, 1}, {{d3, 0, "1->4"}, 0,
>    1}, {{d4, 0, "2->3"}, 0, 1}, {{d5, 0, "2->4"}, 0,
>    1}, {{d6, 0, "3->4"}, 0, 1}};
> Manipulate[
>  Graphics[distances2points[{{0, d1, d2, d3}, {d1, 0, d4, d5}, {d2, d4,
>       0, d6}, {d3, d5, d6, 0}}], PlotRange -> {{-1, 1}, {-1, 1}}],
>  Evaluate[Sequence @@ limits], LocalizeVariables -> False]

```

• Prev by Date: Missing information in Mathematica 6.0 Documentation
• Next by Date: Re: Manipulate with Wrapping SetterBars
• Previous by thread: Similar matrices->similar eigenvectors?
• Next by thread: Re: Similar matrices->similar eigenvectors?