Re: Error in median()
- Posted by CraigWelch May 05, 2020
- 1172 views
Quite so.
I've reverted to my own function, which I wrote way back before the stats package was available. To use this, I changed median() in the code I'm writing to Median(). Simple enough.
--**************************************************************** --********** global function Median **************** --**************************************************************** global function Median (object oInput) -- Input: A sequence of atoms -- Output: The median of those values sequence sTemp integer iIndex if atom(oInput) then return oInput end if if length(oInput) = 1 then return oInput[1] end if sTemp = sort(oInput) if IsOdd(length(sTemp)) then iIndex = floor(length(sTemp) / 2) + 1 return sTemp[iIndex] else iIndex = length(sTemp) / 2 return (sTemp[iIndex] + sTemp[iIndex + 1]) / 2 end if end function