bugGNU Octave - Bugs: bug #29600, median() returns wrong result...

 
 

bug #29600: median() returns wrong result (sometimes)

Submitter:  None
Submitted:  Sun 18 Apr 2010 08:20:02 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Matěj Týč Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.2.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 Apr 2010 04:29:04 AM UTC, comment #1: 

The definition of the median function depends on the number of elements in the dataset.  If the number of elements is odd, then the median is just the middle element of the dataset when they have been ordered from lowest to highest.  If the number of elements is even then the median is equal to the average (mean) of the two middle elements.  See http://en.wikipedia.org/wiki/Median for further reference.

As examples,
median(1:5) = 3
median(1:4) = 2.5 [the average of the two middle elements 2 and 3]

This is not a bug.

Rik <rik5>
Group administrator
Sun 18 Apr 2010 08:20:02 PM UTC, original submission:  

Hello, try running this:

some = rand(4,2);
median(some, 1)

I get this results:
octave:22> some = rand(4,2)
some =

   0.362178   0.605746
   0.383044   0.664575
   0.032583   0.191176
   0.122265   0.993386

octave:23> median(some, 1)
ans =

   0.24222   0.63516

It seems that it is not a median, but a mean value...

Anonymous

 

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

Attach Files:
   
   
Comment:
   

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 rik5 (Posted a comment)
  • -email is unavailable- added by None (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-04-19 rik5 StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code