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

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

[Octave-bug-tracker] [bug #42975] nan: corrcoef function inaccurate


From: Nir Krakauer
Subject: [Octave-bug-tracker] [bug #42975] nan: corrcoef function inaccurate
Date: Wed, 13 Aug 2014 14:46:46 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?42975>

                 Summary: nan: corrcoef function inaccurate
                 Project: GNU Octave
            Submitted by: nir_krakauer
            Submitted on: Wed 13 Aug 2014 02:46:44 PM GMT
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Nir Krakauer
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.6.2
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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.

Examples:
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





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42975>

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




reply via email to

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