octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #8559] statistics package: rewrite of cmds


From: JD Walsh
Subject: [Octave-patch-tracker] [patch #8559] statistics package: rewrite of cmdscale for improved matlab compatibility, mathematical accuracy
Date: Sun, 02 Nov 2014 16:45:14 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0 Iceweasel/33.0

Follow-up Comment #3, patch #8559 (project octave):

I made additional improvements to `cmdscale' and uploaded a new patch. Since
the initial version has already been added to the repository,
`cmdscalefix.patch' includes only changes made between the initial version and
this one.

The initial version of `cmdscale' I uploaded contains a bug. When given an n
by n distance matrix (or a vector corresponding to such a matrix), the
coordinates returned by `cmdscale' should be no greater than
(n-1)-dimensional. However, because of machine approximation `cmdscale'
sometimes returns n-dimensional coordinates. For an example, download the
attached file `testdim.mat' and using the initial version of `cmdscale', do:

> load 'testdim.mat'; [X, e] = cmdscale (D);

Viewing the results shows that `e' contains a small positive eigenvalue
instead of the 0 eigenvalue it should have, and X is 10x10 instead of 10x9, as
it should be.

The initial version of `cmdscale' also needed more input testing and more
informative error messages than `print_usage()'.

I added code ensuring that if `cmdscale' finds n positive eigenvalues, it
throws out the smallest one, since that eigenvalue corresponds to the
approximated zero. This can be tested with `testdim.mat'. I also added more
robust input checking and descriptive error messages. Here are some tests to
illustrate those:

Wrong data types:

> cmdscale (['a','b'; 'b','c']);
> B{1} = 0; B{2} = 0; cmdscale (B);

Wrong matrix forms:

> cmdscale ([1,2,3; 4,5,6]);
> cmdscale ([0,1; 2,0]);
> cmdscale (zeros(3, 3, 3));

Negative entries:

> cmdscale ([0,-1; -1,0]);

Invalid distance matrix:

> cmdscale ([1,2; 2,1]);

(file #32355, file #32356)
    _______________________________________________________

Additional Item Attachment:

File name: cmdscalefix.patch              Size:2 KB
File name: testdim.mat                    Size:2 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8559>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]