10
$\begingroup$

A function can have an average value

$$\frac{1}{b-a}\int_{a}^{b} f(x)dx$$

Can a continuous function have a median?

How would that be computed?

$\endgroup$
  • $\begingroup$ How about $$\frac{\max f+\min f}{2}.$$ $\endgroup$ – Yiorgos S. Smyrlis Oct 6 '14 at 20:26
  • 5
    $\begingroup$ That appears to have nothing to do with the usual notion of median. $\endgroup$ – Kevin Carlson Oct 6 '14 at 20:31
  • $\begingroup$ @Alizter that wouldn't work for x^2? $\endgroup$ – user2321 Oct 6 '14 at 20:49
13
$\begingroup$

That would be $y$ so that the subsets of $[a,b]$

$\{x \in [a,b] \ | \ f(x) \le y\}$ and $\{x \in [a,b] \ | \ f(x) \ge y\}$

have the same measure (with some care).

Obs: if $f$ is monotonous it will be $f(\frac{a+b}{2})$.

$\endgroup$
  • 2
    $\begingroup$ Or more generally, you want the measures of $\{x: f(x) \le y\}$ and $\{x: f(x) \ge y\}$ to be both $\ge 1/2$. $\endgroup$ – Robert Israel Oct 6 '14 at 21:05
  • 1
    $\begingroup$ @Robert Israel: You meant $\frac{b-a}{2}$, yes, and very good point! $\endgroup$ – Orest Bucicovschi Oct 6 '14 at 21:09
3
$\begingroup$

Sure. The median $m$ of a set of numbers $\{x_1,...,x_n\}$ is $x$ so that $x_i\leq x$ for half the $i$ and otherwise $x_i\geq x$-ignoring the details about $n$ being even or odd. So for simplicity suppose $f:[0,1]\to \mathbf{R}$ is continuous. Then we'll define analogously the median of $f$ to be $m$ such that "$f$ is below $m$ half the time and above $m$ half the time," more precisely, such that the length of $\{x:f(x)\leq m\}=1/2$, and similarly for $\{f(x)\geq m\}$. (Here we'll need the convention that we split $\{f(x)=m\}$ evenly to each half, to handle special cases like $f\equiv m$.)

To compute this, we need a function $g$ associated to $f$. Namely, take $g(y)$ to be the length of $\{x:f(x)\leq y\}$. Now $g$ is not necessarily continuous: if for instance $f$ is constant at $m$ as above, then $g(y)=0,y<m, 1\text{ otherwise.}$ But it is "upper continuous", that is, $\lim_{y'\to y^+} g(y')=g(y)$. I'll avoid arguing for this in detail-the point is essentially that if $f(x)\leq y+\epsilon$ for every $\epsilon$ then $f(x)\leq y$. Since $g$ is upper continuous, if we define $m=\inf\{y:g(y)\geq 1/2\}$ then we'll be guaranteed $g(m)\geq 1/2$, and we can define $m$ as our median.

So, this is a lot harder than defining the mean, yes? There are still some issues we haven't worked out: is $g$ even well defined? $\{x:f(x)\leq y\}$ could be an extremely weird set-how do we measure its length? For this we have to defer to a much more advanced topic than calculus, which is called measure theory. However, if $f$ is increasing, then $\{x:f(x)\leq y\}$ will just be an interval, and so we can in principle compute $g$ without any fancy knowledge.

So let's try an example or two. For $f(x)=x,$ we get $g=f$ and $m=1/2$, the same as the means: this shows that linear functions are the continuous analogue of distributions that aren't skewed, which in the finite case are the ones that have the same median as mean. How about $f(x)=x^2$? We get $g(y)=\sqrt y$, so $m=1/4$. But the mean of $x^2$ is $1/3$, so we see $x^2$ is "skewed to the right-"as you can see from its graph! In general, if $f$ is strictly increasing and $f(0)=0$, then as happened here we'll get $g=f^{-1}$, so that it'll be possible to compute the median as $f^{-1}(1/2)$. You can work out similar statements if $f(0)\neq 0$, but to move away from the increasing case things will become increasingly subtle.

$\endgroup$
1
$\begingroup$

Sure a continuous function can have a median, as for if it always has a median I am unsure of.

Let's suppose we have a some function $f$ and it is continuous on $[a,b]$. We want to find its median $m$. We know that if $m$ is a median than if we take any value $c \in [a,b] $ at random then the $P(c \leq m) = $$P(c \geq m) = 1/2 $. Now if we want to construct such a function we need to "normalize" it in a sense.

So let's say we take the integral of $f$ over $[a,b]$ and it is equal to $S$.

$\int_a^b f(x)dx = S$

Now let $=g(x) = \frac{1}{S}f(x)$ so that we have

$\int_a^bg(x)dx = 1$.

Now if we want to find the median of $g(x)$ and therefore $f(x)$ we simply need to find an $m$ such that

$\int_a^mg(x)dx = 1/2$

$\endgroup$
  • 1
    $\begingroup$ -1, I do not believe this is a reasonable definition of the median of a function. In particular, let $f(x) = 7$ over the interval $[0,1]$; by your definition, the median of $f$ would be $\frac12$, when by any (IMO) sensible definition it should be $7$. $\endgroup$ – Ilmari Karonen Oct 6 '14 at 23:21
1
$\begingroup$

Let $X$ be a random variable uniformly distributed over the interval $[a,b]$. If $f : [a,b] \to \mathbb R$ is a (Borel) measurable function, then $Y = f(X)$ is also a random variable, and its distribution can be characterized by all the usual statistical properties, such as the mean and the median.

In particular, the mean of the function $f$, as defined in your question, corresponds exactly to the mean of the random variable $Y$, as given by the law of the unconscious statistician.

Similarly, we can naturally define the median of the function $f$ to be the median of the corresponding random variable $Y$, i.e. a value $m$ such that $\mathrm{Pr}(Y \ge m) \ge \frac12$ and $\mathrm{Pr}(Y \le m) \ge \frac12$.

In particular, since $\mathrm{Pr}(Y \ge m) = \frac{1}{b-a}\mu(\{x \in [a,b]: f(x) \ge m\})$, where $\mu(S) = \int_S 1\, dx$ denotes the measure of the set $S$, and conversely for $\mathrm{Pr}(Y \le m)$, it follows that the median $m$ of $Y$ (and thus of $f$) is simply the value such that the graph of $f$ lies at or below $m$ for half of the interval $[a,b]$, and at or above $m$ for the other half.

(The median, as defined above, may not be unique if $f$ is not continuous. However, if there are multiple values of $m$ that satisfy the definition above, then they will form a single interval. In this sense, the situation is no different from that of the median of a probability distribution in general.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.