The range of a median function

27 Views Asked by At

This question is not about statistics.

We have a median function with 3 parameters and we want to find the range (or the codomain) of the function as an interval. I discovered that it’s eventually the same as the clamp function with 2 constants and 1 variable: $\operatorname{median}(1,x,2) = \operatorname{clamp}(1,x,2) = \max(1,\min(x,2)) \in [1,2]$.

The question is:

  1. What the median function is different from the clamp function is that the parameters can be given in any order and we don’t know which parameters are constants or variables. In this case, how can the range of the function $\operatorname{median}(a,b,c)$ be deducted? (Still assuming 2 constants and 1 variable here.) (I don’t think $[\min(a,b,c),\max(a,b,c)]$ is the optimal solution.)
  2. Is there a general way to find the range of a median function with more parameters?
1

There are 1 best solutions below

0
On

If you have a continuous distribution or you sample with replacement the median can be any number that is part of the distribution. You could pick the low value repeatedly, the high value repeatedly, or anything in between. If you sample a discrete distribution without replacement the median has to be somewhat inside the end points, depending on how many samples you take. If you take five samples, for example, you could pick the lowest five and the median will be the third lowest of the distribution. You could also get the third highest of the distribution or anything in between.