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

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

[Octave-bug-tracker] [bug #59850] uniquetol missing, so I implemented it


From: Rik
Subject: [Octave-bug-tracker] [bug #59850] uniquetol missing, so I implemented it
Date: Sun, 24 Jan 2021 22:10:22 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36

Follow-up Comment #16, bug #59850 (project octave):

Unfortunately my suggestion for a quick algorithm is imperfect.  Consider this
example


x = 1:0.045:3;
y = uniquetol (x, 0.1, 'datascale', 1)


With the quick algorithm this returns just the first value, 1.  But it should
return 1, 1.135, 1.27, ...

The problem is in these two lines


dx = diff (xs);
idx = (dx <= tol);


In this case, all of the differences are .045 which is less than the tolerance
of .1 so the algorithm assumes none of the values besides the first are
unique.  In reality, the differences need to be chained.  The first value is
1, the second is 1.045.  The difference is less than .1 so the algorithm
should continue.  The next value is 1.09.  The difference to the original
value 1 is .09 which is also below .1 so this value is not unique.  Finally
the third value is 1.135 and the difference is .135 which means this last one
is a unique value.

I've thought about using cumsum() on the vector dx and checking when it
exceeds the threshold tol, but this doesn't quite work because I need to reset
the sum of differences to 0 every time a new unique value is found.

Frankly, I'm a bit stumped at the moment.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59850>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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