Skip to content
Prev 247549 / 398506 Next

median by geometric mean

Just in case some of x are negative (the desired median still exists, as 
long as the two middle values are non -ve), how about:

x <- runif(20, -1, 100)
exp(median(log(pmax(0,x))))

It'll give -Inf if the two middle values are negative, when I guess we 
should get NaN, but I can't see a 1-line way to handle that!

Keith J

"Peter Ehlers" <ehlers at ucalgary.ca> wrote in message 
news:4D3468EF.5010601 at ucalgary.ca...