Error in median()

new topic     » topic index » view thread      » older message » newer message

There seems to be an error in the median() function where the number of numbers of which the median is to be found is 2.

The median of 7,8,9 is 8.

The median of 7,9 is also 8.

The Euphoria function, part of the stats include, returns 7. It returns 9 if you use it to get the median of 9,7.

It is clear if you look at the code, which includes:

	if length(data_set) < 3 then 
		return data_set[1] 
	end if 

It would be better to return the average (or mean) of the dataset if the length is 2.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu