Why does the median minimize $E(|X-c|)$?












29












$begingroup$


Suppose $X$ is a real-valued random variable and let $P_X$ denote the distribution of $X$. Then
$$
E(|X-c|) = int_mathbb{R} |x-c| dP_X(x).
$$
The medians of $X$ are defined as any number $m in mathbb{R}$ such that $P(X leq m) geq frac{1}{2}$ and $P(X geq m) geq frac{1}{2}$.



Why do the medians solve
$$
min_{c in mathbb{R}} E(|X-c|) , ?
$$










share|cite|improve this question











$endgroup$

















    29












    $begingroup$


    Suppose $X$ is a real-valued random variable and let $P_X$ denote the distribution of $X$. Then
    $$
    E(|X-c|) = int_mathbb{R} |x-c| dP_X(x).
    $$
    The medians of $X$ are defined as any number $m in mathbb{R}$ such that $P(X leq m) geq frac{1}{2}$ and $P(X geq m) geq frac{1}{2}$.



    Why do the medians solve
    $$
    min_{c in mathbb{R}} E(|X-c|) , ?
    $$










    share|cite|improve this question











    $endgroup$















      29












      29








      29


      23



      $begingroup$


      Suppose $X$ is a real-valued random variable and let $P_X$ denote the distribution of $X$. Then
      $$
      E(|X-c|) = int_mathbb{R} |x-c| dP_X(x).
      $$
      The medians of $X$ are defined as any number $m in mathbb{R}$ such that $P(X leq m) geq frac{1}{2}$ and $P(X geq m) geq frac{1}{2}$.



      Why do the medians solve
      $$
      min_{c in mathbb{R}} E(|X-c|) , ?
      $$










      share|cite|improve this question











      $endgroup$




      Suppose $X$ is a real-valued random variable and let $P_X$ denote the distribution of $X$. Then
      $$
      E(|X-c|) = int_mathbb{R} |x-c| dP_X(x).
      $$
      The medians of $X$ are defined as any number $m in mathbb{R}$ such that $P(X leq m) geq frac{1}{2}$ and $P(X geq m) geq frac{1}{2}$.



      Why do the medians solve
      $$
      min_{c in mathbb{R}} E(|X-c|) , ?
      $$







      probability-theory probability-distributions median






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Oct 18 '16 at 14:35









      Did

      248k23224462




      248k23224462










      asked Nov 25 '11 at 6:58









      TimTim

      16.4k20121324




      16.4k20121324






















          4 Answers
          4






          active

          oldest

          votes


















          25












          $begingroup$

          For every real valued random variable $X$,
          $$
          mathrm E(|X-c|)=int_{-infty}^cmathrm P(Xleqslant t),mathrm dt+int_c^{+infty}mathrm P(Xgeqslant t),mathrm dt
          $$
          hence the function $u:cmapsto mathrm E(|X-c|)$ is differentiable almost everywhere and, where $u'(c)$ exists, $u'(c)=mathrm P(Xleqslant c)-mathrm P(Xgeqslant c)$. Hence $u'(c)leqslant0$ if $c$ is smaller than every median, $u'(c)=0$ if $c$ is a median, and $u'(c)geqslant0$ if $c$ is greater than every median.



          The formula for $mathrm E(|X-c|)$ is the integrated version of the relations $$(x-y)^+=int_y^{+infty}[tleqslant x],mathrm dt$$ and $|x-c|=((-x)-(-c))^++(x-c)^+$, which yield, for every $x$ and $c$,
          $$
          |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[xgeqslant t],mathrm dt
          $$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
            $endgroup$
            – Tim
            Nov 25 '11 at 8:16










          • $begingroup$
            @Rasmus, you are right, thanks, misprint corrected.
            $endgroup$
            – Did
            Nov 25 '11 at 8:21






          • 2




            $begingroup$
            This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
            $endgroup$
            – Evan Aad
            Oct 18 '16 at 9:31








          • 1




            $begingroup$
            @EvanAad Adding convexity to the pot will allow you to conclude.
            $endgroup$
            – Did
            Oct 18 '16 at 16:11






          • 4




            $begingroup$
            @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
            $endgroup$
            – Did
            Nov 24 '16 at 6:03





















          6












          $begingroup$

          Let $f$ be the pdf and let $J(c) = E(|X-c|)$. We want to maximize $J(c)$. Note that $E(|X-c|) = int_{mathbb{R}} |x-c| f(x) dx = int_{-infty}^{c} (c-x) f(x) dx + int_c^{infty} (x-c) f(x) dx.$



          To find the maximum, set $frac{dJ}{dc} = 0$. Hence, we get that,
          $$begin{align}
          frac{dJ}{dc} & = (c-x)f(x) | _{x=c} + int_{-infty}^{c} f(x) dx + (x-c)f(x) | _{x=c} - int_c^{infty} f(x) dx\
          & = int_{-infty}^{c} f(x) dx - int_c^{infty} f(x) dx = 0
          end{align}
          $$



          Hence, we get that $c$ is such that $$int_{-infty}^{c} f(x) dx = int_c^{infty} f(x) dx$$ i.e. $$P(X leq c) = P(X > c).$$



          However, we also know that $P(X leq c) + P(X > c) = 1$. Hence, we get that $$P(X leq c) = P(X > c) = frac12.$$



          EDIT



          When $X$ doesn't have a density, all you need to do is to make use of integration by parts. We get that $$displaystyle int_{-infty}^{c} (c-x) dP(x) = lim_{y rightarrow -infty} (c-y) P(y) + displaystyle int_{c}^{infty} P(x) dx.$$ Similarly, we also get that $$displaystyle int_{c}^{infty} (x-c) dP(x) = lim_{y rightarrow infty} (y-c) P(y) - displaystyle int_{c}^{infty} P(x) dx.$$






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thanks! But does $X$ always have a density?
            $endgroup$
            – Tim
            Nov 25 '11 at 7:09












          • $begingroup$
            @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
            $endgroup$
            – user17762
            Nov 25 '11 at 7:15










          • $begingroup$
            So you are thinking $P$ as cdf of $X$?
            $endgroup$
            – Tim
            Nov 25 '11 at 7:30



















          3












          $begingroup$

          The following intends to complement Did's answer.




          Claim



          Denote by $M$ be the set of $X$'s medians. Then




          1. $M = [m_1, m_2]$ for some $m_1, m_2 in mathbb{R}$, such that $m_1 leq m_2$.


          2. For every $m in M$ and for every $x in mathbb{R}$ we have
            $$
            Eleft(|X-m|right) leq Eleft(|X-x|right).
            $$
            (In particular, $mmapsto Eleft(|X-m|right)$ is constant on $M$.)





          Part 2's proof builds on Did's answer.



          Proof





          1. It is known that $M neq emptyset$. Define
            $$
            begin{align}
            M_1 &:= left{tinmathbb{R} |!: F_X(t) geq frac{1}{2}right}, \
            M_2 &:= left{tinmathbb{R} |!: P(X<t) leq frac{1}{2}right}.
            end{align}
            $$
            Then $M = M_1 cap M_2$. It therefore suffices to show that $M_1 = [m_1, infty)$ and that $M_2 = (-infty, m_2]$, for some $m_1, m_2 in mathbb{R}$.



            Since $lim_{trightarrow-infty}F_X(t) = 0$, $M_1$ is bounded from below. Since $lim_{trightarrowinfty}F_X(t) = 1$, $M_1$ is an interval that extends to infinity. Hence $M_1 = (m_1,infty)$ or $M_1 = [m_1,infty)$, for some $m_1 in mathbb{R}$. It follows from $F_X$'s right-continuity that $m_1 in M_1$. An analogous argument shows that $M_2 = (-infty,m_2]$ (just verify that $tmapsto P(X<t)$ is left-continuous).




          2. Define a function $f:mathbb{R}rightarrowmathbb{R}$ as follows. For every $c in mathbb{R}$, set
            $$
            f(c) := Eleft(|X-c|right).
            $$



            We will begin by showing that $f$ is convex. Let $a, b in mathbb{R}$, and let $t in (0,1)$. Then
            $$
            begin{align}
            fleft(ta+(1-t)bright) &= Eleft(left|X-left(ta+(1-t)bright)right|right) \
            &= Eleft(left|left(tX-taright)+left((1-t)X-(1-t)bright)right|right) \
            &leq Eleft(left|left(tX-taright)right|+left|left((1-t)X-(1-t)bright)right|right) \
            &=Eleft(left|left(tX-taright)right|right)+Eleft(left|left((1-t)X-(1-t)bright)right|right) \
            &= t Eleft(|X-a|right) + (1-t) Eleft(|X-b|right) \
            &= t f(a) + (1-t) f(b).
            end{align}
            $$



            Since $f$ is convex, then, by Theorem 7.40 of [1] (p. 157), there exists a set $A subseteq mathbb{R}$ such that $mathbb{R}setminus A$ is countable, and such that $f$ is finitely differentiable on $A$. Moreover, letting $m in M$, and letting $x in (-infty, m_1)$, Theorem 7.43 of [1] (p. 158) yields that $f'$ is Lebesgue-integrable on $[x,m] cap A$, and that
            $$
            f(m) - f(x) = int_{[x,m]cap A} f' dlambda.
            $$



            Applying Did's answer, we find that $f'leq 0$ on $[x,m]cap A$. Hence $f(m) leq f(x)$. Similar considerations show that, for every $x in (m_2,infty)$, $f(m) leq f(x)$, and also that $f(m) = f(m_1)$ (implying that $f$ is constant on $M$, since $m$ was chosen arbitrarily in $M$).



            (The argument of the last paragraph was suggested to me by copper.hat in their answer to a related question of mine.)




          Q.E.D.





          References



          [1] Richard L. Wheeden and Antoni Zygmund. Measure and Integral: An Introduction to Real Analysis. 2nd Ed. 2015. CRC Press. ISBN: 978-1-4987-0290-4.






          share|cite|improve this answer











          $endgroup$













          • $begingroup$
            Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
            $endgroup$
            – Vim
            Nov 24 '16 at 3:17








          • 1




            $begingroup$
            @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
            $endgroup$
            – Evan Aad
            Nov 24 '16 at 9:54










          • $begingroup$
            I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
            $endgroup$
            – Vim
            Nov 24 '16 at 10:06












          • $begingroup$
            @Vim: My proof covers the case that $M$ is a singleton.
            $endgroup$
            – Evan Aad
            Nov 24 '16 at 12:33










          • $begingroup$
            indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
            $endgroup$
            – Vim
            Nov 24 '16 at 12:40



















          3












          $begingroup$

          Let $m$ be any median of $X$. Wlog, we can take $m=0$ (consider $X':=X-m$). The aim is to show $E|X-c|ge E|X|$.



          Consider the case $cge 0$. It is straightforward to check that $|X-c|-|X|=c$ when $Xle0$, and $|X-c|-|X|ge -c$ when $X>0$.



          It follows that
          $$
          Eleft[(|X-c|-|X|)I(Xle0)right]=cP(Xle0)tag1
          $$

          and
          $$Eleft[(|X-c|-|X|)I(X>0)right]ge-cP(X>0).tag2
          $$

          Adding (1) and (2) yields
          $$
          E(|X-c|-|X|)ge cleft[P(Xle0)-P(X>0)right].tag3
          $$

          The RHS of (3) equals $c[2P(Xle0)-1]$, which is non-negative since $cge0$ and zero is a median of $X$. The case $cle0$ is reduced to the previous one by considering $X':=-X$ and $c':=-c$.






          share|cite|improve this answer











          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "69"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f85448%2fwhy-does-the-median-minimize-ex-c%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            25












            $begingroup$

            For every real valued random variable $X$,
            $$
            mathrm E(|X-c|)=int_{-infty}^cmathrm P(Xleqslant t),mathrm dt+int_c^{+infty}mathrm P(Xgeqslant t),mathrm dt
            $$
            hence the function $u:cmapsto mathrm E(|X-c|)$ is differentiable almost everywhere and, where $u'(c)$ exists, $u'(c)=mathrm P(Xleqslant c)-mathrm P(Xgeqslant c)$. Hence $u'(c)leqslant0$ if $c$ is smaller than every median, $u'(c)=0$ if $c$ is a median, and $u'(c)geqslant0$ if $c$ is greater than every median.



            The formula for $mathrm E(|X-c|)$ is the integrated version of the relations $$(x-y)^+=int_y^{+infty}[tleqslant x],mathrm dt$$ and $|x-c|=((-x)-(-c))^++(x-c)^+$, which yield, for every $x$ and $c$,
            $$
            |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[xgeqslant t],mathrm dt
            $$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
              $endgroup$
              – Tim
              Nov 25 '11 at 8:16










            • $begingroup$
              @Rasmus, you are right, thanks, misprint corrected.
              $endgroup$
              – Did
              Nov 25 '11 at 8:21






            • 2




              $begingroup$
              This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
              $endgroup$
              – Evan Aad
              Oct 18 '16 at 9:31








            • 1




              $begingroup$
              @EvanAad Adding convexity to the pot will allow you to conclude.
              $endgroup$
              – Did
              Oct 18 '16 at 16:11






            • 4




              $begingroup$
              @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
              $endgroup$
              – Did
              Nov 24 '16 at 6:03


















            25












            $begingroup$

            For every real valued random variable $X$,
            $$
            mathrm E(|X-c|)=int_{-infty}^cmathrm P(Xleqslant t),mathrm dt+int_c^{+infty}mathrm P(Xgeqslant t),mathrm dt
            $$
            hence the function $u:cmapsto mathrm E(|X-c|)$ is differentiable almost everywhere and, where $u'(c)$ exists, $u'(c)=mathrm P(Xleqslant c)-mathrm P(Xgeqslant c)$. Hence $u'(c)leqslant0$ if $c$ is smaller than every median, $u'(c)=0$ if $c$ is a median, and $u'(c)geqslant0$ if $c$ is greater than every median.



            The formula for $mathrm E(|X-c|)$ is the integrated version of the relations $$(x-y)^+=int_y^{+infty}[tleqslant x],mathrm dt$$ and $|x-c|=((-x)-(-c))^++(x-c)^+$, which yield, for every $x$ and $c$,
            $$
            |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[xgeqslant t],mathrm dt
            $$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
              $endgroup$
              – Tim
              Nov 25 '11 at 8:16










            • $begingroup$
              @Rasmus, you are right, thanks, misprint corrected.
              $endgroup$
              – Did
              Nov 25 '11 at 8:21






            • 2




              $begingroup$
              This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
              $endgroup$
              – Evan Aad
              Oct 18 '16 at 9:31








            • 1




              $begingroup$
              @EvanAad Adding convexity to the pot will allow you to conclude.
              $endgroup$
              – Did
              Oct 18 '16 at 16:11






            • 4




              $begingroup$
              @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
              $endgroup$
              – Did
              Nov 24 '16 at 6:03
















            25












            25








            25





            $begingroup$

            For every real valued random variable $X$,
            $$
            mathrm E(|X-c|)=int_{-infty}^cmathrm P(Xleqslant t),mathrm dt+int_c^{+infty}mathrm P(Xgeqslant t),mathrm dt
            $$
            hence the function $u:cmapsto mathrm E(|X-c|)$ is differentiable almost everywhere and, where $u'(c)$ exists, $u'(c)=mathrm P(Xleqslant c)-mathrm P(Xgeqslant c)$. Hence $u'(c)leqslant0$ if $c$ is smaller than every median, $u'(c)=0$ if $c$ is a median, and $u'(c)geqslant0$ if $c$ is greater than every median.



            The formula for $mathrm E(|X-c|)$ is the integrated version of the relations $$(x-y)^+=int_y^{+infty}[tleqslant x],mathrm dt$$ and $|x-c|=((-x)-(-c))^++(x-c)^+$, which yield, for every $x$ and $c$,
            $$
            |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[xgeqslant t],mathrm dt
            $$






            share|cite|improve this answer











            $endgroup$



            For every real valued random variable $X$,
            $$
            mathrm E(|X-c|)=int_{-infty}^cmathrm P(Xleqslant t),mathrm dt+int_c^{+infty}mathrm P(Xgeqslant t),mathrm dt
            $$
            hence the function $u:cmapsto mathrm E(|X-c|)$ is differentiable almost everywhere and, where $u'(c)$ exists, $u'(c)=mathrm P(Xleqslant c)-mathrm P(Xgeqslant c)$. Hence $u'(c)leqslant0$ if $c$ is smaller than every median, $u'(c)=0$ if $c$ is a median, and $u'(c)geqslant0$ if $c$ is greater than every median.



            The formula for $mathrm E(|X-c|)$ is the integrated version of the relations $$(x-y)^+=int_y^{+infty}[tleqslant x],mathrm dt$$ and $|x-c|=((-x)-(-c))^++(x-c)^+$, which yield, for every $x$ and $c$,
            $$
            |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[xgeqslant t],mathrm dt
            $$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Nov 24 '16 at 6:04

























            answered Nov 25 '11 at 7:54









            DidDid

            248k23224462




            248k23224462












            • $begingroup$
              Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
              $endgroup$
              – Tim
              Nov 25 '11 at 8:16










            • $begingroup$
              @Rasmus, you are right, thanks, misprint corrected.
              $endgroup$
              – Did
              Nov 25 '11 at 8:21






            • 2




              $begingroup$
              This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
              $endgroup$
              – Evan Aad
              Oct 18 '16 at 9:31








            • 1




              $begingroup$
              @EvanAad Adding convexity to the pot will allow you to conclude.
              $endgroup$
              – Did
              Oct 18 '16 at 16:11






            • 4




              $begingroup$
              @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
              $endgroup$
              – Did
              Nov 24 '16 at 6:03




















            • $begingroup$
              Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
              $endgroup$
              – Tim
              Nov 25 '11 at 8:16










            • $begingroup$
              @Rasmus, you are right, thanks, misprint corrected.
              $endgroup$
              – Did
              Nov 25 '11 at 8:21






            • 2




              $begingroup$
              This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
              $endgroup$
              – Evan Aad
              Oct 18 '16 at 9:31








            • 1




              $begingroup$
              @EvanAad Adding convexity to the pot will allow you to conclude.
              $endgroup$
              – Did
              Oct 18 '16 at 16:11






            • 4




              $begingroup$
              @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
              $endgroup$
              – Did
              Nov 24 '16 at 6:03


















            $begingroup$
            Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
            $endgroup$
            – Tim
            Nov 25 '11 at 8:16




            $begingroup$
            Thanks! (1) By "integrated version", is it to first integrate your last formula wrt $P$ over $mathbb{R}$, then apply Fubini Thm to exchange the order of the two integrals, and so get the first formula? (2) If temporarily change the notation $P$ to represent the cdf of $X$, is Sivaram's Edit correct? Specifically, do those Riemann-Stieltjes integrals exist?
            $endgroup$
            – Tim
            Nov 25 '11 at 8:16












            $begingroup$
            @Rasmus, you are right, thanks, misprint corrected.
            $endgroup$
            – Did
            Nov 25 '11 at 8:21




            $begingroup$
            @Rasmus, you are right, thanks, misprint corrected.
            $endgroup$
            – Did
            Nov 25 '11 at 8:21




            2




            2




            $begingroup$
            This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
            $endgroup$
            – Evan Aad
            Oct 18 '16 at 9:31






            $begingroup$
            This is a very nice proof. A clarification for future readers, who, like me, would be perplexed by the notation $[xleq-t]$ and $[xgeq t]$: If $A$ is an event, $[A]$ denotes the indicator function $mathbb{1}_A$. In particular, $[xleq-t] = mathbb{1}_{{x leq -t}}$, and likewise $[xgeq t] = mathbb{1}_{{xgeq t}}$.
            $endgroup$
            – Evan Aad
            Oct 18 '16 at 9:31






            1




            1




            $begingroup$
            @EvanAad Adding convexity to the pot will allow you to conclude.
            $endgroup$
            – Did
            Oct 18 '16 at 16:11




            $begingroup$
            @EvanAad Adding convexity to the pot will allow you to conclude.
            $endgroup$
            – Did
            Oct 18 '16 at 16:11




            4




            4




            $begingroup$
            @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
            $endgroup$
            – Did
            Nov 24 '16 at 6:03






            $begingroup$
            @Vim The convexity of the function $u$ makes these objections moot, but here is a more direct route: for every $x$ and $c$, $$ |x-c|=int_{-infty}^c[xleqslant t],mathrm dt+int_c^{+infty}[x>t],mathrm dt $$ hence, for every median $m$, $$E(|X-c|)=E(|X-m|)+int_m^cv(t)dt$$ with $$v(t)=P(Xleqslant t)-P(X>t)=2P(Xleqslant t)-1$$ Then $v$ is nondecreasing and $v(m)geqslant0$ hence, for every $c>m$, $vgeqslant0$ on $(m,c)$, which implies $E(|X-c|)geqslant E(|X-m|)$. Likewise for $c<m$.
            $endgroup$
            – Did
            Nov 24 '16 at 6:03













            6












            $begingroup$

            Let $f$ be the pdf and let $J(c) = E(|X-c|)$. We want to maximize $J(c)$. Note that $E(|X-c|) = int_{mathbb{R}} |x-c| f(x) dx = int_{-infty}^{c} (c-x) f(x) dx + int_c^{infty} (x-c) f(x) dx.$



            To find the maximum, set $frac{dJ}{dc} = 0$. Hence, we get that,
            $$begin{align}
            frac{dJ}{dc} & = (c-x)f(x) | _{x=c} + int_{-infty}^{c} f(x) dx + (x-c)f(x) | _{x=c} - int_c^{infty} f(x) dx\
            & = int_{-infty}^{c} f(x) dx - int_c^{infty} f(x) dx = 0
            end{align}
            $$



            Hence, we get that $c$ is such that $$int_{-infty}^{c} f(x) dx = int_c^{infty} f(x) dx$$ i.e. $$P(X leq c) = P(X > c).$$



            However, we also know that $P(X leq c) + P(X > c) = 1$. Hence, we get that $$P(X leq c) = P(X > c) = frac12.$$



            EDIT



            When $X$ doesn't have a density, all you need to do is to make use of integration by parts. We get that $$displaystyle int_{-infty}^{c} (c-x) dP(x) = lim_{y rightarrow -infty} (c-y) P(y) + displaystyle int_{c}^{infty} P(x) dx.$$ Similarly, we also get that $$displaystyle int_{c}^{infty} (x-c) dP(x) = lim_{y rightarrow infty} (y-c) P(y) - displaystyle int_{c}^{infty} P(x) dx.$$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Thanks! But does $X$ always have a density?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:09












            • $begingroup$
              @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
              $endgroup$
              – user17762
              Nov 25 '11 at 7:15










            • $begingroup$
              So you are thinking $P$ as cdf of $X$?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:30
















            6












            $begingroup$

            Let $f$ be the pdf and let $J(c) = E(|X-c|)$. We want to maximize $J(c)$. Note that $E(|X-c|) = int_{mathbb{R}} |x-c| f(x) dx = int_{-infty}^{c} (c-x) f(x) dx + int_c^{infty} (x-c) f(x) dx.$



            To find the maximum, set $frac{dJ}{dc} = 0$. Hence, we get that,
            $$begin{align}
            frac{dJ}{dc} & = (c-x)f(x) | _{x=c} + int_{-infty}^{c} f(x) dx + (x-c)f(x) | _{x=c} - int_c^{infty} f(x) dx\
            & = int_{-infty}^{c} f(x) dx - int_c^{infty} f(x) dx = 0
            end{align}
            $$



            Hence, we get that $c$ is such that $$int_{-infty}^{c} f(x) dx = int_c^{infty} f(x) dx$$ i.e. $$P(X leq c) = P(X > c).$$



            However, we also know that $P(X leq c) + P(X > c) = 1$. Hence, we get that $$P(X leq c) = P(X > c) = frac12.$$



            EDIT



            When $X$ doesn't have a density, all you need to do is to make use of integration by parts. We get that $$displaystyle int_{-infty}^{c} (c-x) dP(x) = lim_{y rightarrow -infty} (c-y) P(y) + displaystyle int_{c}^{infty} P(x) dx.$$ Similarly, we also get that $$displaystyle int_{c}^{infty} (x-c) dP(x) = lim_{y rightarrow infty} (y-c) P(y) - displaystyle int_{c}^{infty} P(x) dx.$$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Thanks! But does $X$ always have a density?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:09












            • $begingroup$
              @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
              $endgroup$
              – user17762
              Nov 25 '11 at 7:15










            • $begingroup$
              So you are thinking $P$ as cdf of $X$?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:30














            6












            6








            6





            $begingroup$

            Let $f$ be the pdf and let $J(c) = E(|X-c|)$. We want to maximize $J(c)$. Note that $E(|X-c|) = int_{mathbb{R}} |x-c| f(x) dx = int_{-infty}^{c} (c-x) f(x) dx + int_c^{infty} (x-c) f(x) dx.$



            To find the maximum, set $frac{dJ}{dc} = 0$. Hence, we get that,
            $$begin{align}
            frac{dJ}{dc} & = (c-x)f(x) | _{x=c} + int_{-infty}^{c} f(x) dx + (x-c)f(x) | _{x=c} - int_c^{infty} f(x) dx\
            & = int_{-infty}^{c} f(x) dx - int_c^{infty} f(x) dx = 0
            end{align}
            $$



            Hence, we get that $c$ is such that $$int_{-infty}^{c} f(x) dx = int_c^{infty} f(x) dx$$ i.e. $$P(X leq c) = P(X > c).$$



            However, we also know that $P(X leq c) + P(X > c) = 1$. Hence, we get that $$P(X leq c) = P(X > c) = frac12.$$



            EDIT



            When $X$ doesn't have a density, all you need to do is to make use of integration by parts. We get that $$displaystyle int_{-infty}^{c} (c-x) dP(x) = lim_{y rightarrow -infty} (c-y) P(y) + displaystyle int_{c}^{infty} P(x) dx.$$ Similarly, we also get that $$displaystyle int_{c}^{infty} (x-c) dP(x) = lim_{y rightarrow infty} (y-c) P(y) - displaystyle int_{c}^{infty} P(x) dx.$$






            share|cite|improve this answer











            $endgroup$



            Let $f$ be the pdf and let $J(c) = E(|X-c|)$. We want to maximize $J(c)$. Note that $E(|X-c|) = int_{mathbb{R}} |x-c| f(x) dx = int_{-infty}^{c} (c-x) f(x) dx + int_c^{infty} (x-c) f(x) dx.$



            To find the maximum, set $frac{dJ}{dc} = 0$. Hence, we get that,
            $$begin{align}
            frac{dJ}{dc} & = (c-x)f(x) | _{x=c} + int_{-infty}^{c} f(x) dx + (x-c)f(x) | _{x=c} - int_c^{infty} f(x) dx\
            & = int_{-infty}^{c} f(x) dx - int_c^{infty} f(x) dx = 0
            end{align}
            $$



            Hence, we get that $c$ is such that $$int_{-infty}^{c} f(x) dx = int_c^{infty} f(x) dx$$ i.e. $$P(X leq c) = P(X > c).$$



            However, we also know that $P(X leq c) + P(X > c) = 1$. Hence, we get that $$P(X leq c) = P(X > c) = frac12.$$



            EDIT



            When $X$ doesn't have a density, all you need to do is to make use of integration by parts. We get that $$displaystyle int_{-infty}^{c} (c-x) dP(x) = lim_{y rightarrow -infty} (c-y) P(y) + displaystyle int_{c}^{infty} P(x) dx.$$ Similarly, we also get that $$displaystyle int_{c}^{infty} (x-c) dP(x) = lim_{y rightarrow infty} (y-c) P(y) - displaystyle int_{c}^{infty} P(x) dx.$$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Nov 25 '11 at 7:38

























            answered Nov 25 '11 at 7:07







            user17762



















            • $begingroup$
              Thanks! But does $X$ always have a density?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:09












            • $begingroup$
              @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
              $endgroup$
              – user17762
              Nov 25 '11 at 7:15










            • $begingroup$
              So you are thinking $P$ as cdf of $X$?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:30


















            • $begingroup$
              Thanks! But does $X$ always have a density?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:09












            • $begingroup$
              @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
              $endgroup$
              – user17762
              Nov 25 '11 at 7:15










            • $begingroup$
              So you are thinking $P$ as cdf of $X$?
              $endgroup$
              – Tim
              Nov 25 '11 at 7:30
















            $begingroup$
            Thanks! But does $X$ always have a density?
            $endgroup$
            – Tim
            Nov 25 '11 at 7:09






            $begingroup$
            Thanks! But does $X$ always have a density?
            $endgroup$
            – Tim
            Nov 25 '11 at 7:09














            $begingroup$
            @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
            $endgroup$
            – user17762
            Nov 25 '11 at 7:15




            $begingroup$
            @Tim: I don't think it is hard to adapt the same idea for the case when $X$ doesn't have a density.
            $endgroup$
            – user17762
            Nov 25 '11 at 7:15












            $begingroup$
            So you are thinking $P$ as cdf of $X$?
            $endgroup$
            – Tim
            Nov 25 '11 at 7:30




            $begingroup$
            So you are thinking $P$ as cdf of $X$?
            $endgroup$
            – Tim
            Nov 25 '11 at 7:30











            3












            $begingroup$

            The following intends to complement Did's answer.




            Claim



            Denote by $M$ be the set of $X$'s medians. Then




            1. $M = [m_1, m_2]$ for some $m_1, m_2 in mathbb{R}$, such that $m_1 leq m_2$.


            2. For every $m in M$ and for every $x in mathbb{R}$ we have
              $$
              Eleft(|X-m|right) leq Eleft(|X-x|right).
              $$
              (In particular, $mmapsto Eleft(|X-m|right)$ is constant on $M$.)





            Part 2's proof builds on Did's answer.



            Proof





            1. It is known that $M neq emptyset$. Define
              $$
              begin{align}
              M_1 &:= left{tinmathbb{R} |!: F_X(t) geq frac{1}{2}right}, \
              M_2 &:= left{tinmathbb{R} |!: P(X<t) leq frac{1}{2}right}.
              end{align}
              $$
              Then $M = M_1 cap M_2$. It therefore suffices to show that $M_1 = [m_1, infty)$ and that $M_2 = (-infty, m_2]$, for some $m_1, m_2 in mathbb{R}$.



              Since $lim_{trightarrow-infty}F_X(t) = 0$, $M_1$ is bounded from below. Since $lim_{trightarrowinfty}F_X(t) = 1$, $M_1$ is an interval that extends to infinity. Hence $M_1 = (m_1,infty)$ or $M_1 = [m_1,infty)$, for some $m_1 in mathbb{R}$. It follows from $F_X$'s right-continuity that $m_1 in M_1$. An analogous argument shows that $M_2 = (-infty,m_2]$ (just verify that $tmapsto P(X<t)$ is left-continuous).




            2. Define a function $f:mathbb{R}rightarrowmathbb{R}$ as follows. For every $c in mathbb{R}$, set
              $$
              f(c) := Eleft(|X-c|right).
              $$



              We will begin by showing that $f$ is convex. Let $a, b in mathbb{R}$, and let $t in (0,1)$. Then
              $$
              begin{align}
              fleft(ta+(1-t)bright) &= Eleft(left|X-left(ta+(1-t)bright)right|right) \
              &= Eleft(left|left(tX-taright)+left((1-t)X-(1-t)bright)right|right) \
              &leq Eleft(left|left(tX-taright)right|+left|left((1-t)X-(1-t)bright)right|right) \
              &=Eleft(left|left(tX-taright)right|right)+Eleft(left|left((1-t)X-(1-t)bright)right|right) \
              &= t Eleft(|X-a|right) + (1-t) Eleft(|X-b|right) \
              &= t f(a) + (1-t) f(b).
              end{align}
              $$



              Since $f$ is convex, then, by Theorem 7.40 of [1] (p. 157), there exists a set $A subseteq mathbb{R}$ such that $mathbb{R}setminus A$ is countable, and such that $f$ is finitely differentiable on $A$. Moreover, letting $m in M$, and letting $x in (-infty, m_1)$, Theorem 7.43 of [1] (p. 158) yields that $f'$ is Lebesgue-integrable on $[x,m] cap A$, and that
              $$
              f(m) - f(x) = int_{[x,m]cap A} f' dlambda.
              $$



              Applying Did's answer, we find that $f'leq 0$ on $[x,m]cap A$. Hence $f(m) leq f(x)$. Similar considerations show that, for every $x in (m_2,infty)$, $f(m) leq f(x)$, and also that $f(m) = f(m_1)$ (implying that $f$ is constant on $M$, since $m$ was chosen arbitrarily in $M$).



              (The argument of the last paragraph was suggested to me by copper.hat in their answer to a related question of mine.)




            Q.E.D.





            References



            [1] Richard L. Wheeden and Antoni Zygmund. Measure and Integral: An Introduction to Real Analysis. 2nd Ed. 2015. CRC Press. ISBN: 978-1-4987-0290-4.






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
              $endgroup$
              – Vim
              Nov 24 '16 at 3:17








            • 1




              $begingroup$
              @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 9:54










            • $begingroup$
              I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
              $endgroup$
              – Vim
              Nov 24 '16 at 10:06












            • $begingroup$
              @Vim: My proof covers the case that $M$ is a singleton.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 12:33










            • $begingroup$
              indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
              $endgroup$
              – Vim
              Nov 24 '16 at 12:40
















            3












            $begingroup$

            The following intends to complement Did's answer.




            Claim



            Denote by $M$ be the set of $X$'s medians. Then




            1. $M = [m_1, m_2]$ for some $m_1, m_2 in mathbb{R}$, such that $m_1 leq m_2$.


            2. For every $m in M$ and for every $x in mathbb{R}$ we have
              $$
              Eleft(|X-m|right) leq Eleft(|X-x|right).
              $$
              (In particular, $mmapsto Eleft(|X-m|right)$ is constant on $M$.)





            Part 2's proof builds on Did's answer.



            Proof





            1. It is known that $M neq emptyset$. Define
              $$
              begin{align}
              M_1 &:= left{tinmathbb{R} |!: F_X(t) geq frac{1}{2}right}, \
              M_2 &:= left{tinmathbb{R} |!: P(X<t) leq frac{1}{2}right}.
              end{align}
              $$
              Then $M = M_1 cap M_2$. It therefore suffices to show that $M_1 = [m_1, infty)$ and that $M_2 = (-infty, m_2]$, for some $m_1, m_2 in mathbb{R}$.



              Since $lim_{trightarrow-infty}F_X(t) = 0$, $M_1$ is bounded from below. Since $lim_{trightarrowinfty}F_X(t) = 1$, $M_1$ is an interval that extends to infinity. Hence $M_1 = (m_1,infty)$ or $M_1 = [m_1,infty)$, for some $m_1 in mathbb{R}$. It follows from $F_X$'s right-continuity that $m_1 in M_1$. An analogous argument shows that $M_2 = (-infty,m_2]$ (just verify that $tmapsto P(X<t)$ is left-continuous).




            2. Define a function $f:mathbb{R}rightarrowmathbb{R}$ as follows. For every $c in mathbb{R}$, set
              $$
              f(c) := Eleft(|X-c|right).
              $$



              We will begin by showing that $f$ is convex. Let $a, b in mathbb{R}$, and let $t in (0,1)$. Then
              $$
              begin{align}
              fleft(ta+(1-t)bright) &= Eleft(left|X-left(ta+(1-t)bright)right|right) \
              &= Eleft(left|left(tX-taright)+left((1-t)X-(1-t)bright)right|right) \
              &leq Eleft(left|left(tX-taright)right|+left|left((1-t)X-(1-t)bright)right|right) \
              &=Eleft(left|left(tX-taright)right|right)+Eleft(left|left((1-t)X-(1-t)bright)right|right) \
              &= t Eleft(|X-a|right) + (1-t) Eleft(|X-b|right) \
              &= t f(a) + (1-t) f(b).
              end{align}
              $$



              Since $f$ is convex, then, by Theorem 7.40 of [1] (p. 157), there exists a set $A subseteq mathbb{R}$ such that $mathbb{R}setminus A$ is countable, and such that $f$ is finitely differentiable on $A$. Moreover, letting $m in M$, and letting $x in (-infty, m_1)$, Theorem 7.43 of [1] (p. 158) yields that $f'$ is Lebesgue-integrable on $[x,m] cap A$, and that
              $$
              f(m) - f(x) = int_{[x,m]cap A} f' dlambda.
              $$



              Applying Did's answer, we find that $f'leq 0$ on $[x,m]cap A$. Hence $f(m) leq f(x)$. Similar considerations show that, for every $x in (m_2,infty)$, $f(m) leq f(x)$, and also that $f(m) = f(m_1)$ (implying that $f$ is constant on $M$, since $m$ was chosen arbitrarily in $M$).



              (The argument of the last paragraph was suggested to me by copper.hat in their answer to a related question of mine.)




            Q.E.D.





            References



            [1] Richard L. Wheeden and Antoni Zygmund. Measure and Integral: An Introduction to Real Analysis. 2nd Ed. 2015. CRC Press. ISBN: 978-1-4987-0290-4.






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
              $endgroup$
              – Vim
              Nov 24 '16 at 3:17








            • 1




              $begingroup$
              @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 9:54










            • $begingroup$
              I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
              $endgroup$
              – Vim
              Nov 24 '16 at 10:06












            • $begingroup$
              @Vim: My proof covers the case that $M$ is a singleton.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 12:33










            • $begingroup$
              indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
              $endgroup$
              – Vim
              Nov 24 '16 at 12:40














            3












            3








            3





            $begingroup$

            The following intends to complement Did's answer.




            Claim



            Denote by $M$ be the set of $X$'s medians. Then




            1. $M = [m_1, m_2]$ for some $m_1, m_2 in mathbb{R}$, such that $m_1 leq m_2$.


            2. For every $m in M$ and for every $x in mathbb{R}$ we have
              $$
              Eleft(|X-m|right) leq Eleft(|X-x|right).
              $$
              (In particular, $mmapsto Eleft(|X-m|right)$ is constant on $M$.)





            Part 2's proof builds on Did's answer.



            Proof





            1. It is known that $M neq emptyset$. Define
              $$
              begin{align}
              M_1 &:= left{tinmathbb{R} |!: F_X(t) geq frac{1}{2}right}, \
              M_2 &:= left{tinmathbb{R} |!: P(X<t) leq frac{1}{2}right}.
              end{align}
              $$
              Then $M = M_1 cap M_2$. It therefore suffices to show that $M_1 = [m_1, infty)$ and that $M_2 = (-infty, m_2]$, for some $m_1, m_2 in mathbb{R}$.



              Since $lim_{trightarrow-infty}F_X(t) = 0$, $M_1$ is bounded from below. Since $lim_{trightarrowinfty}F_X(t) = 1$, $M_1$ is an interval that extends to infinity. Hence $M_1 = (m_1,infty)$ or $M_1 = [m_1,infty)$, for some $m_1 in mathbb{R}$. It follows from $F_X$'s right-continuity that $m_1 in M_1$. An analogous argument shows that $M_2 = (-infty,m_2]$ (just verify that $tmapsto P(X<t)$ is left-continuous).




            2. Define a function $f:mathbb{R}rightarrowmathbb{R}$ as follows. For every $c in mathbb{R}$, set
              $$
              f(c) := Eleft(|X-c|right).
              $$



              We will begin by showing that $f$ is convex. Let $a, b in mathbb{R}$, and let $t in (0,1)$. Then
              $$
              begin{align}
              fleft(ta+(1-t)bright) &= Eleft(left|X-left(ta+(1-t)bright)right|right) \
              &= Eleft(left|left(tX-taright)+left((1-t)X-(1-t)bright)right|right) \
              &leq Eleft(left|left(tX-taright)right|+left|left((1-t)X-(1-t)bright)right|right) \
              &=Eleft(left|left(tX-taright)right|right)+Eleft(left|left((1-t)X-(1-t)bright)right|right) \
              &= t Eleft(|X-a|right) + (1-t) Eleft(|X-b|right) \
              &= t f(a) + (1-t) f(b).
              end{align}
              $$



              Since $f$ is convex, then, by Theorem 7.40 of [1] (p. 157), there exists a set $A subseteq mathbb{R}$ such that $mathbb{R}setminus A$ is countable, and such that $f$ is finitely differentiable on $A$. Moreover, letting $m in M$, and letting $x in (-infty, m_1)$, Theorem 7.43 of [1] (p. 158) yields that $f'$ is Lebesgue-integrable on $[x,m] cap A$, and that
              $$
              f(m) - f(x) = int_{[x,m]cap A} f' dlambda.
              $$



              Applying Did's answer, we find that $f'leq 0$ on $[x,m]cap A$. Hence $f(m) leq f(x)$. Similar considerations show that, for every $x in (m_2,infty)$, $f(m) leq f(x)$, and also that $f(m) = f(m_1)$ (implying that $f$ is constant on $M$, since $m$ was chosen arbitrarily in $M$).



              (The argument of the last paragraph was suggested to me by copper.hat in their answer to a related question of mine.)




            Q.E.D.





            References



            [1] Richard L. Wheeden and Antoni Zygmund. Measure and Integral: An Introduction to Real Analysis. 2nd Ed. 2015. CRC Press. ISBN: 978-1-4987-0290-4.






            share|cite|improve this answer











            $endgroup$



            The following intends to complement Did's answer.




            Claim



            Denote by $M$ be the set of $X$'s medians. Then




            1. $M = [m_1, m_2]$ for some $m_1, m_2 in mathbb{R}$, such that $m_1 leq m_2$.


            2. For every $m in M$ and for every $x in mathbb{R}$ we have
              $$
              Eleft(|X-m|right) leq Eleft(|X-x|right).
              $$
              (In particular, $mmapsto Eleft(|X-m|right)$ is constant on $M$.)





            Part 2's proof builds on Did's answer.



            Proof





            1. It is known that $M neq emptyset$. Define
              $$
              begin{align}
              M_1 &:= left{tinmathbb{R} |!: F_X(t) geq frac{1}{2}right}, \
              M_2 &:= left{tinmathbb{R} |!: P(X<t) leq frac{1}{2}right}.
              end{align}
              $$
              Then $M = M_1 cap M_2$. It therefore suffices to show that $M_1 = [m_1, infty)$ and that $M_2 = (-infty, m_2]$, for some $m_1, m_2 in mathbb{R}$.



              Since $lim_{trightarrow-infty}F_X(t) = 0$, $M_1$ is bounded from below. Since $lim_{trightarrowinfty}F_X(t) = 1$, $M_1$ is an interval that extends to infinity. Hence $M_1 = (m_1,infty)$ or $M_1 = [m_1,infty)$, for some $m_1 in mathbb{R}$. It follows from $F_X$'s right-continuity that $m_1 in M_1$. An analogous argument shows that $M_2 = (-infty,m_2]$ (just verify that $tmapsto P(X<t)$ is left-continuous).




            2. Define a function $f:mathbb{R}rightarrowmathbb{R}$ as follows. For every $c in mathbb{R}$, set
              $$
              f(c) := Eleft(|X-c|right).
              $$



              We will begin by showing that $f$ is convex. Let $a, b in mathbb{R}$, and let $t in (0,1)$. Then
              $$
              begin{align}
              fleft(ta+(1-t)bright) &= Eleft(left|X-left(ta+(1-t)bright)right|right) \
              &= Eleft(left|left(tX-taright)+left((1-t)X-(1-t)bright)right|right) \
              &leq Eleft(left|left(tX-taright)right|+left|left((1-t)X-(1-t)bright)right|right) \
              &=Eleft(left|left(tX-taright)right|right)+Eleft(left|left((1-t)X-(1-t)bright)right|right) \
              &= t Eleft(|X-a|right) + (1-t) Eleft(|X-b|right) \
              &= t f(a) + (1-t) f(b).
              end{align}
              $$



              Since $f$ is convex, then, by Theorem 7.40 of [1] (p. 157), there exists a set $A subseteq mathbb{R}$ such that $mathbb{R}setminus A$ is countable, and such that $f$ is finitely differentiable on $A$. Moreover, letting $m in M$, and letting $x in (-infty, m_1)$, Theorem 7.43 of [1] (p. 158) yields that $f'$ is Lebesgue-integrable on $[x,m] cap A$, and that
              $$
              f(m) - f(x) = int_{[x,m]cap A} f' dlambda.
              $$



              Applying Did's answer, we find that $f'leq 0$ on $[x,m]cap A$. Hence $f(m) leq f(x)$. Similar considerations show that, for every $x in (m_2,infty)$, $f(m) leq f(x)$, and also that $f(m) = f(m_1)$ (implying that $f$ is constant on $M$, since $m$ was chosen arbitrarily in $M$).



              (The argument of the last paragraph was suggested to me by copper.hat in their answer to a related question of mine.)




            Q.E.D.





            References



            [1] Richard L. Wheeden and Antoni Zygmund. Measure and Integral: An Introduction to Real Analysis. 2nd Ed. 2015. CRC Press. ISBN: 978-1-4987-0290-4.







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Apr 13 '17 at 12:21









            Community

            1




            1










            answered Oct 18 '16 at 20:10









            Evan AadEvan Aad

            5,60911854




            5,60911854












            • $begingroup$
              Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
              $endgroup$
              – Vim
              Nov 24 '16 at 3:17








            • 1




              $begingroup$
              @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 9:54










            • $begingroup$
              I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
              $endgroup$
              – Vim
              Nov 24 '16 at 10:06












            • $begingroup$
              @Vim: My proof covers the case that $M$ is a singleton.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 12:33










            • $begingroup$
              indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
              $endgroup$
              – Vim
              Nov 24 '16 at 12:40


















            • $begingroup$
              Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
              $endgroup$
              – Vim
              Nov 24 '16 at 3:17








            • 1




              $begingroup$
              @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 9:54










            • $begingroup$
              I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
              $endgroup$
              – Vim
              Nov 24 '16 at 10:06












            • $begingroup$
              @Vim: My proof covers the case that $M$ is a singleton.
              $endgroup$
              – Evan Aad
              Nov 24 '16 at 12:33










            • $begingroup$
              indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
              $endgroup$
              – Vim
              Nov 24 '16 at 12:40
















            $begingroup$
            Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
            $endgroup$
            – Vim
            Nov 24 '16 at 3:17






            $begingroup$
            Thanks. Now I understand why if $M$ is an interval then any point where $f$ assumes zero derivative is a global minimiser of $f$. However, what if $M$ is a singleton and $f$ is not differentiable there? (Also, could you give the name of the Lebesgue integrability theorem you invoked?)
            $endgroup$
            – Vim
            Nov 24 '16 at 3:17






            1




            1




            $begingroup$
            @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
            $endgroup$
            – Evan Aad
            Nov 24 '16 at 9:54




            $begingroup$
            @Vim: 1. A singleton ${s}$ is an interval of the from $[m_1, m_2]$, $m_1leq m_2$ with $m_1:=m_2:=s$. 2. Here's a link to the theorem.
            $endgroup$
            – Evan Aad
            Nov 24 '16 at 9:54












            $begingroup$
            I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
            $endgroup$
            – Vim
            Nov 24 '16 at 10:06






            $begingroup$
            I was not asking whether a singleton is an interval or not, rather, I was thinking the how to apply the convexity in this case. Anyway it seems already solved to me now: even though $f$ can fail to be differentiable at this point, its left and right derivatives surely exist by convexity, and the left one is $le 0$ and the right one $ge 0$ by the definition of the median.
            $endgroup$
            – Vim
            Nov 24 '16 at 10:06














            $begingroup$
            @Vim: My proof covers the case that $M$ is a singleton.
            $endgroup$
            – Evan Aad
            Nov 24 '16 at 12:33




            $begingroup$
            @Vim: My proof covers the case that $M$ is a singleton.
            $endgroup$
            – Evan Aad
            Nov 24 '16 at 12:33












            $begingroup$
            indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
            $endgroup$
            – Vim
            Nov 24 '16 at 12:40




            $begingroup$
            indeed. I had been actually mainly reading the link in your answer, which seemed a bit simpler so that I could grasp it with less knowledge basis. The singleton concern arose from there but not from this answer.
            $endgroup$
            – Vim
            Nov 24 '16 at 12:40











            3












            $begingroup$

            Let $m$ be any median of $X$. Wlog, we can take $m=0$ (consider $X':=X-m$). The aim is to show $E|X-c|ge E|X|$.



            Consider the case $cge 0$. It is straightforward to check that $|X-c|-|X|=c$ when $Xle0$, and $|X-c|-|X|ge -c$ when $X>0$.



            It follows that
            $$
            Eleft[(|X-c|-|X|)I(Xle0)right]=cP(Xle0)tag1
            $$

            and
            $$Eleft[(|X-c|-|X|)I(X>0)right]ge-cP(X>0).tag2
            $$

            Adding (1) and (2) yields
            $$
            E(|X-c|-|X|)ge cleft[P(Xle0)-P(X>0)right].tag3
            $$

            The RHS of (3) equals $c[2P(Xle0)-1]$, which is non-negative since $cge0$ and zero is a median of $X$. The case $cle0$ is reduced to the previous one by considering $X':=-X$ and $c':=-c$.






            share|cite|improve this answer











            $endgroup$


















              3












              $begingroup$

              Let $m$ be any median of $X$. Wlog, we can take $m=0$ (consider $X':=X-m$). The aim is to show $E|X-c|ge E|X|$.



              Consider the case $cge 0$. It is straightforward to check that $|X-c|-|X|=c$ when $Xle0$, and $|X-c|-|X|ge -c$ when $X>0$.



              It follows that
              $$
              Eleft[(|X-c|-|X|)I(Xle0)right]=cP(Xle0)tag1
              $$

              and
              $$Eleft[(|X-c|-|X|)I(X>0)right]ge-cP(X>0).tag2
              $$

              Adding (1) and (2) yields
              $$
              E(|X-c|-|X|)ge cleft[P(Xle0)-P(X>0)right].tag3
              $$

              The RHS of (3) equals $c[2P(Xle0)-1]$, which is non-negative since $cge0$ and zero is a median of $X$. The case $cle0$ is reduced to the previous one by considering $X':=-X$ and $c':=-c$.






              share|cite|improve this answer











              $endgroup$
















                3












                3








                3





                $begingroup$

                Let $m$ be any median of $X$. Wlog, we can take $m=0$ (consider $X':=X-m$). The aim is to show $E|X-c|ge E|X|$.



                Consider the case $cge 0$. It is straightforward to check that $|X-c|-|X|=c$ when $Xle0$, and $|X-c|-|X|ge -c$ when $X>0$.



                It follows that
                $$
                Eleft[(|X-c|-|X|)I(Xle0)right]=cP(Xle0)tag1
                $$

                and
                $$Eleft[(|X-c|-|X|)I(X>0)right]ge-cP(X>0).tag2
                $$

                Adding (1) and (2) yields
                $$
                E(|X-c|-|X|)ge cleft[P(Xle0)-P(X>0)right].tag3
                $$

                The RHS of (3) equals $c[2P(Xle0)-1]$, which is non-negative since $cge0$ and zero is a median of $X$. The case $cle0$ is reduced to the previous one by considering $X':=-X$ and $c':=-c$.






                share|cite|improve this answer











                $endgroup$



                Let $m$ be any median of $X$. Wlog, we can take $m=0$ (consider $X':=X-m$). The aim is to show $E|X-c|ge E|X|$.



                Consider the case $cge 0$. It is straightforward to check that $|X-c|-|X|=c$ when $Xle0$, and $|X-c|-|X|ge -c$ when $X>0$.



                It follows that
                $$
                Eleft[(|X-c|-|X|)I(Xle0)right]=cP(Xle0)tag1
                $$

                and
                $$Eleft[(|X-c|-|X|)I(X>0)right]ge-cP(X>0).tag2
                $$

                Adding (1) and (2) yields
                $$
                E(|X-c|-|X|)ge cleft[P(Xle0)-P(X>0)right].tag3
                $$

                The RHS of (3) equals $c[2P(Xle0)-1]$, which is non-negative since $cge0$ and zero is a median of $X$. The case $cle0$ is reduced to the previous one by considering $X':=-X$ and $c':=-c$.







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited Nov 18 '18 at 13:55









                amWhy

                1




                1










                answered May 21 '18 at 18:05









                grand_chatgrand_chat

                20.3k11326




                20.3k11326






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f85448%2fwhy-does-the-median-minimize-ex-c%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Quarter-circle Tiles

                    build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                    Mont Emei