bugGNU Octave - Bugs: bug #50377, pdist2 function returns complex...

 
 

bug #50377: pdist2 function returns complex results

Submitted by:  Georg Wiora <gwiora>
Submitted on:  Wed Feb 22 08:09:21 2017  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Inaccurate Result
Status: NoneAssigned to: None
Originator Name: gwioraOpen/Closed: Open
Release: 4.2.0Operating System: Any

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Wed Mar 1 15:13:13 2017, comment #3:

I reviewed your "max()" suggestion and now aggree that this is the better solution. The code segement below should the be changed to the following code:

Georg Wiora <gwiora>
Wed Feb 22 09:55:15 2017, comment #2:

I thought about that too. I think the numeric result is in both cases equal to a precision of eps. But the abs function is in terms of memory use and complexity maybe more efficient than the solution using max().

Please correct me if my understanding is wrong. The max solution is definitely "more" precise in its result.

Georg Wiora <gwiora>
Wed Feb 22 09:47:51 2017, comment #1:

What about using max (., 0) instead of abs (.) ?

Guillaume <gyom>
Wed Feb 22 08:09:21 2017, original submission:

For certain cases the pdist2 function from statistics package may return complex results leading to unexpected behaviour in following calculations. The complex results are caused by a negative result for "dists" in the distEucSq() local function:

The negative results are caused by rounding errors and are in the range of -1e-16. A single negative value in dists array causes the whole result array in case of euclidian distance calculation (default for pdist2) to become complex data type.

Suggested solution:
Add an abs() function for squared distances_

I have appended a patched version of pdist2.m.

Georg Wiora <gwiora>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #39810:  pdist2.m added by gwiora (5kB - application/octet-stream - Patched version of pdist2 function.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by gyom (Posted a comment)
  • -unavailable- added by gwiora (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Feb 22 08:09:21 2017gwioraAttached File-=>Added pdist2.m, #39810

    Back to the top


    Powered by Savane 3.1-cleanup1