octave-maintainers
[Top][All Lists]
Advanced

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

Re: Patching cov.m on current stable


From: Ismael Núñez-Riboni
Subject: Re: Patching cov.m on current stable
Date: Mon, 12 Mar 2012 21:59:23 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

We've discussed cov incompatibilities before.  Please look at this
thread:

http://octave.1599824.n4.nabble.com/covariance-matrix-td1607376.html#a1607378

I see now that Octave's cov function has advantages over the Matlab version, which seems to me (without having a Matlab license to try on) that can only be mimicked in Matlab with a loop... I agree thus that Octave's cov function is better than the Matlab version. However, I disagree with the behavior being more intuitive than in Matlab. Contrary to the comments in that link, I see the actual behavior of Octave's cov function as counter-intuitive but I must say I'm strongly biased by almost 20 years of Matlab use. I think Matlab's behavior seems more logical for observational scientists (I'm myself an observational physicist) and engineers (it might be non intiutive for mathematicians or theoretical physicists, though): Normally you have two sets or time series X,Y and in matlab you get besides the covariance between the two vectors also their auto-covariances, i.e., you obtain the 2x2 covariance matrix. In octave you only get the covariance between the vectors unless you join them into a Nx2 matrix. I don't think that ex matlab users will easily get to find out that, even though the help of the Octave's function is clear enough and correct... to find out the mismatch with matlab's version you really have to read the help text carefully or get an error message when you are porting your code to Octave (my case).

I can suggest thus to write a warning in the help of the functions which are supposed to work differently than in Matlab, something like:

Warning: please note the behavior of cov is different than in matlab!

And/or to detail the behavior of the function with a couple of examples to drag attention to a different behavior. In Matlab's help this information:

"cov(X) is the covariance matrix. diag(cov(X)) is a vector of variances for each column, and sqrt(diag(cov(X))) is a vector of standard deviations"

is completely redundant, you can live without it, but it helps a lot to many users to understand the behavior of the function. Why not to include something similar in Octave's cov function to clearly state that its behavior is different than in Matlab? I can suggest to add to octave's cov help:

For two column vectors X and Y, cov([X,Y]) yields the covariance matrix between X and Y, while cov(X,Y) yields the scalar covariance.

I stress it: I am aware that this information is redundant with what already is written in the cov's help and most probably a new user to Octave will not need this explanation, but an ex matlab user could really get into troubles without it...

Finally: I guess you are aware that with Octave's cov function you are breaking compatibility with Matlab, even though the Octave's version of cov is better... But I guess that the decision of sticking to Matlab compatibility or improving functionality is not easy... For me, the more and more I use Octave I kind of think I don't need Matlab's compatibility anymore, but unfortunately I still exchange a lot of code with Matlab's users... Why not, in the case, to make "second version functions" (like with a "2" at the end, like cov2, or an "i" of "improved", like cov_i) for those functions incompatible with Matlab but which should exist because they are better?

Cheers, Ismael.


reply via email to

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