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

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

[Octave-bug-tracker] [bug #51329] nth_element / median function fail wit


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #51329] nth_element / median function fail with disable_range(true) (or with --traditional)
Date: Wed, 28 Jun 2017 18:53:05 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0

Update of bug #51329 (project octave):

                  Status:                    None => Confirmed              
                 Summary: Median fails due to nth_element in --traditional =>
nth_element / median function fail with disable_range(true) (or with
--traditional)

    _______________________________________________________

Follow-up Comment #10:

The algorithm is relying on the input being both sorted and a contiguous range
of integers.

The suggested patch in comment #3 may work in this limited case where the
argument looks like it should be a contiguous range, but falls apart in other
cases.

Allowing an arbitrary index vector as the second argument would need a lot
more code than suggested here so far, making this a more expensive operation
in that case, to either verify that the vector is indeed a contiguous sorted
range of integers, or to recursively call nth_element for each distinct index
value for example.

I can confirm that nth_element (and thus median) do fail when disable_range
has been set:


>> test ("median");
PASSES 18 out of 18 tests
>> disable_range (true);
>> test ("median");
***** test
 x = [1, 2, 3, 4, 5, 6];
 x2 = x';
 y = [1, 2, 3, 4, 5, 6, 7];
 y2 = y';

 assert (median (x) == median (x2) && median (x) == 3.5);
 assert (median (y) == median (y2) && median (y) == 4);
 assert (median ([x2, 2*x2]), [3.5, 7]);
 assert (median ([y2, 3*y2]), [4, 12]);
!!!!! test failed
nth_element: n must be a scalar or a contiguous range



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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