bugGNU Octave - Bugs: bug #42975, [octave forge] (nan) corrcoef...


bug #42975: [octave forge] (nan) corrcoef function inaccurate

Submitter:  Nir Krakauer <nir_krakauer>
Submitted:  Wed 13 Aug 2014 02:46:44 PM UTC
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Nir Krakauer Open/Closed:  * Open
Release:  * other Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Wed 13 Aug 2014 02:46:44 PM UTC, original submission:  

The corrcoef function in the nan package uses a numerically unstable method to calculate the correlation coefficients, which can even result in the returned correlation coefficients being outside the range -1 to 1.

A) i = 1E7; c = corrcoef(1E5 + (1:i)'/i, 1E5 + sin((1:i)'/i) .* cos((1:i)'/i)) returns 1.0518
B) i = 1E6; c = corrcoef(1E7+(1:i)'/i, 1E7 + sin((1:i)'/i)) returns -1.2129
C) i = 1E6; c = corrcoef(1E7+(1:i)'/i, 1E7 - sin((1:i)'/i)) returns 0.00000 - 0.43355i

By contrast, for the above cases the built-in corrcoef function returns reasonable results of 0.92305, 0.99743, -0.99743 respectively

Nir Krakauer <nir_krakauer>


(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 nir_krakauer (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-11-19 mtmiller Carbon-CopyRemoved 80942 -
    2017-08-13 jwe Summarynan: corrcoef function inaccurate [octave forge] (nan) corrcoef function inaccurate
    2016-01-18 mtmiller Release3.6.2 other

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code