bugGNU Octave - Bugs: bug #33541, corrcoef Matlab compatibility issue


bug #33541: corrcoef Matlab compatibility issue

Submitted by:  Arnaud Delorme <arnodelorme>
Submitted on:  Sat 11 Jun 2011 03:49:25 PM UTC  
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  3.4.0 Operating System:  Mac OS

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sun 17 Jul 2011 03:43:09 AM UTC, comment #8:

I've deprecated both corrcoef() and cor(), and added the new function corr() which calculates the same concept as Matlab. The changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/cad4cba03f19) is on the development branch and the reporter will need to build from source in order to see the change.

Rik <rik5>
Project Administrator
Sun 17 Jul 2011 03:01:28 AM UTC, comment #7:


This seems correct to me.

Michael Godfrey <godfrey>
Project Member
Sun 17 Jul 2011 02:03:33 AM UTC, comment #6:


What do you think of simply renaming the current corrcoef to corr() since that seems to be the name Matlab uses for the output that Octave calculates? The description for corr() is here <http://www.mathworks.com/help/toolbox/stats/corr.html>

Rik <rik5>
Project Administrator
Mon 13 Jun 2011 03:55:40 PM UTC, comment #5:

Note that the corr function of the Matlab statistics toolbox behave as the current corrcoef function of Octave.

Arnaud Delorme <arnodelorme>
Mon 13 Jun 2011 04:48:13 AM UTC, comment #4:

Besides compatability, can someone make a
compelling argument for why this behavior is better than the current Octave

I agree that the Matlab behavior is weird at best.

It might make sense to explain this incompatibility
somewhere, and how to deal with it.

Somewhat more generally, few statisticians use Matlab,
because Matlab has never been serious about statistics.
So, matching their statistical functions should have low

For serious statistics R is the choice.

Michael Godfrey <godfrey>
Project Member
Mon 13 Jun 2011 03:48:28 AM UTC, comment #3:

I just took a look at the Matlab function as well and I dislike their interpretation of corrcoef(x,y) quite a bit. The correlation coefficient between two vectors of observations is a single number. Mathworks interprets corrcoef(x,y) as corrcoef ([x y]) which is a correlation coefficient matrix. For a vector the elements on the diagonals are obviously 1 because each vector x,y correlates with itself and the off-diagonal element is what I would call the correlation coefficient. Besides compatability, can someone make a compelling argument for why this behavior is better than the current Octave behavior?

If necessary, it is trivial to achieve compatibility manually by calling corrcoef ([x y]). I would have users do this if they really want this behavior.

Rik <rik5>
Project Administrator
Mon 13 Jun 2011 03:27:28 AM UTC, comment #2:

I took a quick look at the Matlab function.
It is quite different from the Octave one.

So, it may be necessary to decide on a major
chance which will introduce incompatibility
for Octave.

The documentation is fairly clear for both Matlab
and Octave. Just different.

Michael Godfrey <godfrey>
Project Member
Mon 13 Jun 2011 03:16:12 AM UTC, comment #1:

Can you explain why Matlab is different in this instance? It seems to me that the correlation coefficient of two vectors SHOULD be a single number (1x1).

Rik <rik5>
Project Administrator
Sat 11 Jun 2011 03:49:25 PM UTC, original submission:

corrcoef(rand(5,1), rand(5,1)) 
% return 1x1 matrix Octave (2x2 Matlab with 1 in the diagonal)

Arnaud Delorme <arnodelorme>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arnodelorme (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-07-17 rik5 StatusNeed Info => Fixed
        Open/ClosedOpen => Closed
    2011-06-29 jwe Item GroupIncorrect Result => Matlab Compatibility
    2011-06-13 rik5 StatusNone => Need Info

    Back to the top

    Powered by Savane 3.3