Opened 13 years ago

Closed 13 years ago

#660 closed defect (fixed)

median crashes on empty range

Reported by: Peter Owned by: Peter
Priority: minor Milestone: yat 0.7.2
Component: statistics Version: 0.7.1
Keywords: Cc:


I tried to calculate the median of an empty range

median(x.begin(), x.end(), true)

where x is empty so x.begin()==x.end(). The program crashes with segmentation fault. I think yat should detect this and either return NaN or throw an exception.


Change History (3)

comment:1 Changed 13 years ago by Peter

Component: teststatistics
Milestone: yat 0.x+yat 0.7.2
Owner: changed from Jari Häkkinen to Peter
Priority: majorminor

the relevant code is in class Percentiler

comment:2 Changed 13 years ago by Peter

Status: newassigned

Given that Averager::mean() returns NaN when empty, I think median should also return NaN.

comment:3 Changed 13 years ago by Peter

Resolution: fixed
Status: assignedclosed

(In [2444]) fixes #660

Note: See TracTickets for help on using tickets.