Calculate mean and variance of a cone-shaped distribution in N-dimensions

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I would like to calculate the mean and variance of a cone-shaped distribution,



$f(x) propto exp(-|x|)$,



where $xinmathbbR^d$, where $d$ can be any positive integer.



In two-dimensions, this distribution looks like,
enter image description here



a cone! I can calculate the normalising constant for this distribution using,



Integrate[Exp[-Norm[x,y]], x, -Infinity, Infinity, y, -Infinity, Infinity]


which is $2pi$. I can then calculate the mean normed distance using,



Integrate[Norm[x,y]Exp[-Norm[x,y]], x, -Infinity, Infinity,
y, -Infinity, Infinity]


which is 2. Its second moment,



Integrate[Norm[x,y]^2Exp[-Norm[x,y]], x, -Infinity, Infinity,
y, -Infinity, Infinity]


then allows me to calculate the variance ($var(x) = E(x^2) - E(x)^2$) = 2.



Calculating the normalising constants is easy enough in higher dimensions, but I run into trouble with finding the mean and variance.



Any ideas?



I'm guessing that something can maybe be done using polar coordinates in higher dimensions but this isn't something I know much about!










share|improve this question

























    up vote
    2
    down vote

    favorite












    I would like to calculate the mean and variance of a cone-shaped distribution,



    $f(x) propto exp(-|x|)$,



    where $xinmathbbR^d$, where $d$ can be any positive integer.



    In two-dimensions, this distribution looks like,
    enter image description here



    a cone! I can calculate the normalising constant for this distribution using,



    Integrate[Exp[-Norm[x,y]], x, -Infinity, Infinity, y, -Infinity, Infinity]


    which is $2pi$. I can then calculate the mean normed distance using,



    Integrate[Norm[x,y]Exp[-Norm[x,y]], x, -Infinity, Infinity,
    y, -Infinity, Infinity]


    which is 2. Its second moment,



    Integrate[Norm[x,y]^2Exp[-Norm[x,y]], x, -Infinity, Infinity,
    y, -Infinity, Infinity]


    then allows me to calculate the variance ($var(x) = E(x^2) - E(x)^2$) = 2.



    Calculating the normalising constants is easy enough in higher dimensions, but I run into trouble with finding the mean and variance.



    Any ideas?



    I'm guessing that something can maybe be done using polar coordinates in higher dimensions but this isn't something I know much about!










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I would like to calculate the mean and variance of a cone-shaped distribution,



      $f(x) propto exp(-|x|)$,



      where $xinmathbbR^d$, where $d$ can be any positive integer.



      In two-dimensions, this distribution looks like,
      enter image description here



      a cone! I can calculate the normalising constant for this distribution using,



      Integrate[Exp[-Norm[x,y]], x, -Infinity, Infinity, y, -Infinity, Infinity]


      which is $2pi$. I can then calculate the mean normed distance using,



      Integrate[Norm[x,y]Exp[-Norm[x,y]], x, -Infinity, Infinity,
      y, -Infinity, Infinity]


      which is 2. Its second moment,



      Integrate[Norm[x,y]^2Exp[-Norm[x,y]], x, -Infinity, Infinity,
      y, -Infinity, Infinity]


      then allows me to calculate the variance ($var(x) = E(x^2) - E(x)^2$) = 2.



      Calculating the normalising constants is easy enough in higher dimensions, but I run into trouble with finding the mean and variance.



      Any ideas?



      I'm guessing that something can maybe be done using polar coordinates in higher dimensions but this isn't something I know much about!










      share|improve this question













      I would like to calculate the mean and variance of a cone-shaped distribution,



      $f(x) propto exp(-|x|)$,



      where $xinmathbbR^d$, where $d$ can be any positive integer.



      In two-dimensions, this distribution looks like,
      enter image description here



      a cone! I can calculate the normalising constant for this distribution using,



      Integrate[Exp[-Norm[x,y]], x, -Infinity, Infinity, y, -Infinity, Infinity]


      which is $2pi$. I can then calculate the mean normed distance using,



      Integrate[Norm[x,y]Exp[-Norm[x,y]], x, -Infinity, Infinity,
      y, -Infinity, Infinity]


      which is 2. Its second moment,



      Integrate[Norm[x,y]^2Exp[-Norm[x,y]], x, -Infinity, Infinity,
      y, -Infinity, Infinity]


      then allows me to calculate the variance ($var(x) = E(x^2) - E(x)^2$) = 2.



      Calculating the normalising constants is easy enough in higher dimensions, but I run into trouble with finding the mean and variance.



      Any ideas?



      I'm guessing that something can maybe be done using polar coordinates in higher dimensions but this isn't something I know much about!







      numerical-integration probability-or-statistics geometry






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 46 mins ago









      ben18785

      1,351622




      1,351622




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The expected value of the random variable should always be 0 due to symmetry.



          For the normalization, we need to determine $omega$ such that



          $$omega , int_mathbbR^n mathrme^- , mathrmdx = 1.$$



          The expected distance to the origin is



          $$omega , int_mathbbR^n |x|^1 , mathrme^- , mathrmdx.$$



          For the variance, we have to compute



          $$omega , int_mathbbR^n |x|^2 , mathrme^- , mathrmdx.$$



          All these integrals are radially symmetric.



          By introducing polar coorinates, we obtain
          $$int_mathbbR^n |x|^alpha , mathrme^- , mathrmdx =int_S^n-1int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r , mathrmdS = omega_n int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r,$$



          where $omega_n = frac(2 pi )^n/2Gamma left(fracn2right)$ is the surface area of the unit sphere.



          Such integrals can be computed symbolically by Mathematica:



          v[α_, n_] = (2 π)^(n/2)/Gamma[n/2] Integrate[r^α Exp[-r] r^(n - 1), r, 0, ∞, 
          Assumptions -> α + n > 0]



          $$ frac(2 pi )^n/2 Gamma (n+alpha )Gamma
          left(fracn2right)$$




          So, the variance should equal



          var[n_] = FullSimplify[
          v[2, n]/v[0, n],
          n ∈ Integers && n > 0]



          $n (1 + n)$




          var /@ Range[10]



          2, 6, 12, 20, 30, 42, 56, 72, 90, 110




          Edit



          The expectation of the norm can be obtained by



          normexpection[n_] = FullSimplify[
          v[1, n]/v[0, n],
          n ∈ Integers && n > 0
          ]



          n







          share|improve this answer






















          • Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
            – ben18785
            8 mins ago










          • You're welcome.
            – Henrik Schumacher
            3 mins ago

















          up vote
          2
          down vote













          ClearAll[aa, nc, dist]
          aa[n_Integer] := Array[x, n];
          nc[n_Integer] := 2^n*Pi^((n - 1)/2)*Gamma[(1 + n)/2]
          dist[n_Integer] := ProbabilityDistribution[Exp[-Norm[aa[n]]]/nc[n],
          ## & @@ Thread[aa[n], -∞, ∞]]

          Expectation[Norm[aa[#]], Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



          2, 3, 4, 5




          Expectation[Norm[aa[#]]^2, Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



          6, 12, 20, 30




          Also:



          td[n_Integer] := TransformedDistribution[Norm[aa[n]], Distributed[aa[n], dist[n]]]

          Mean[td[#]] & /@ Range[2, 5]



          2, 3, 4, 5




          Moment[td[#], 2] & /@ Range[2, 5]



          6, 12, 20, 30




          Variance[td[#]] & /@ Range[2, 5]



          2, 3, 4, 5







          share|improve this answer






















            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: "387"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182508%2fcalculate-mean-and-variance-of-a-cone-shaped-distribution-in-n-dimensions%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            The expected value of the random variable should always be 0 due to symmetry.



            For the normalization, we need to determine $omega$ such that



            $$omega , int_mathbbR^n mathrme^- , mathrmdx = 1.$$



            The expected distance to the origin is



            $$omega , int_mathbbR^n |x|^1 , mathrme^- , mathrmdx.$$



            For the variance, we have to compute



            $$omega , int_mathbbR^n |x|^2 , mathrme^- , mathrmdx.$$



            All these integrals are radially symmetric.



            By introducing polar coorinates, we obtain
            $$int_mathbbR^n |x|^alpha , mathrme^- , mathrmdx =int_S^n-1int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r , mathrmdS = omega_n int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r,$$



            where $omega_n = frac(2 pi )^n/2Gamma left(fracn2right)$ is the surface area of the unit sphere.



            Such integrals can be computed symbolically by Mathematica:



            v[α_, n_] = (2 π)^(n/2)/Gamma[n/2] Integrate[r^α Exp[-r] r^(n - 1), r, 0, ∞, 
            Assumptions -> α + n > 0]



            $$ frac(2 pi )^n/2 Gamma (n+alpha )Gamma
            left(fracn2right)$$




            So, the variance should equal



            var[n_] = FullSimplify[
            v[2, n]/v[0, n],
            n ∈ Integers && n > 0]



            $n (1 + n)$




            var /@ Range[10]



            2, 6, 12, 20, 30, 42, 56, 72, 90, 110




            Edit



            The expectation of the norm can be obtained by



            normexpection[n_] = FullSimplify[
            v[1, n]/v[0, n],
            n ∈ Integers && n > 0
            ]



            n







            share|improve this answer






















            • Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
              – ben18785
              8 mins ago










            • You're welcome.
              – Henrik Schumacher
              3 mins ago














            up vote
            1
            down vote



            accepted










            The expected value of the random variable should always be 0 due to symmetry.



            For the normalization, we need to determine $omega$ such that



            $$omega , int_mathbbR^n mathrme^- , mathrmdx = 1.$$



            The expected distance to the origin is



            $$omega , int_mathbbR^n |x|^1 , mathrme^- , mathrmdx.$$



            For the variance, we have to compute



            $$omega , int_mathbbR^n |x|^2 , mathrme^- , mathrmdx.$$



            All these integrals are radially symmetric.



            By introducing polar coorinates, we obtain
            $$int_mathbbR^n |x|^alpha , mathrme^- , mathrmdx =int_S^n-1int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r , mathrmdS = omega_n int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r,$$



            where $omega_n = frac(2 pi )^n/2Gamma left(fracn2right)$ is the surface area of the unit sphere.



            Such integrals can be computed symbolically by Mathematica:



            v[α_, n_] = (2 π)^(n/2)/Gamma[n/2] Integrate[r^α Exp[-r] r^(n - 1), r, 0, ∞, 
            Assumptions -> α + n > 0]



            $$ frac(2 pi )^n/2 Gamma (n+alpha )Gamma
            left(fracn2right)$$




            So, the variance should equal



            var[n_] = FullSimplify[
            v[2, n]/v[0, n],
            n ∈ Integers && n > 0]



            $n (1 + n)$




            var /@ Range[10]



            2, 6, 12, 20, 30, 42, 56, 72, 90, 110




            Edit



            The expectation of the norm can be obtained by



            normexpection[n_] = FullSimplify[
            v[1, n]/v[0, n],
            n ∈ Integers && n > 0
            ]



            n







            share|improve this answer






















            • Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
              – ben18785
              8 mins ago










            • You're welcome.
              – Henrik Schumacher
              3 mins ago












            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            The expected value of the random variable should always be 0 due to symmetry.



            For the normalization, we need to determine $omega$ such that



            $$omega , int_mathbbR^n mathrme^- , mathrmdx = 1.$$



            The expected distance to the origin is



            $$omega , int_mathbbR^n |x|^1 , mathrme^- , mathrmdx.$$



            For the variance, we have to compute



            $$omega , int_mathbbR^n |x|^2 , mathrme^- , mathrmdx.$$



            All these integrals are radially symmetric.



            By introducing polar coorinates, we obtain
            $$int_mathbbR^n |x|^alpha , mathrme^- , mathrmdx =int_S^n-1int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r , mathrmdS = omega_n int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r,$$



            where $omega_n = frac(2 pi )^n/2Gamma left(fracn2right)$ is the surface area of the unit sphere.



            Such integrals can be computed symbolically by Mathematica:



            v[α_, n_] = (2 π)^(n/2)/Gamma[n/2] Integrate[r^α Exp[-r] r^(n - 1), r, 0, ∞, 
            Assumptions -> α + n > 0]



            $$ frac(2 pi )^n/2 Gamma (n+alpha )Gamma
            left(fracn2right)$$




            So, the variance should equal



            var[n_] = FullSimplify[
            v[2, n]/v[0, n],
            n ∈ Integers && n > 0]



            $n (1 + n)$




            var /@ Range[10]



            2, 6, 12, 20, 30, 42, 56, 72, 90, 110




            Edit



            The expectation of the norm can be obtained by



            normexpection[n_] = FullSimplify[
            v[1, n]/v[0, n],
            n ∈ Integers && n > 0
            ]



            n







            share|improve this answer














            The expected value of the random variable should always be 0 due to symmetry.



            For the normalization, we need to determine $omega$ such that



            $$omega , int_mathbbR^n mathrme^- , mathrmdx = 1.$$



            The expected distance to the origin is



            $$omega , int_mathbbR^n |x|^1 , mathrme^- , mathrmdx.$$



            For the variance, we have to compute



            $$omega , int_mathbbR^n |x|^2 , mathrme^- , mathrmdx.$$



            All these integrals are radially symmetric.



            By introducing polar coorinates, we obtain
            $$int_mathbbR^n |x|^alpha , mathrme^- , mathrmdx =int_S^n-1int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r , mathrmdS = omega_n int_0^infty mathrme^-r , r^alpha+n-1 , mathrmd r,$$



            where $omega_n = frac(2 pi )^n/2Gamma left(fracn2right)$ is the surface area of the unit sphere.



            Such integrals can be computed symbolically by Mathematica:



            v[α_, n_] = (2 π)^(n/2)/Gamma[n/2] Integrate[r^α Exp[-r] r^(n - 1), r, 0, ∞, 
            Assumptions -> α + n > 0]



            $$ frac(2 pi )^n/2 Gamma (n+alpha )Gamma
            left(fracn2right)$$




            So, the variance should equal



            var[n_] = FullSimplify[
            v[2, n]/v[0, n],
            n ∈ Integers && n > 0]



            $n (1 + n)$




            var /@ Range[10]



            2, 6, 12, 20, 30, 42, 56, 72, 90, 110




            Edit



            The expectation of the norm can be obtained by



            normexpection[n_] = FullSimplify[
            v[1, n]/v[0, n],
            n ∈ Integers && n > 0
            ]



            n








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 1 min ago

























            answered 16 mins ago









            Henrik Schumacher

            39k254115




            39k254115











            • Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
              – ben18785
              8 mins ago










            • You're welcome.
              – Henrik Schumacher
              3 mins ago
















            • Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
              – ben18785
              8 mins ago










            • You're welcome.
              – Henrik Schumacher
              3 mins ago















            Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
            – ben18785
            8 mins ago




            Thanks! Just a small thing, the expectation shouldn't be zero because I am calculating the expectation of the normed x, not x itself.
            – ben18785
            8 mins ago












            You're welcome.
            – Henrik Schumacher
            3 mins ago




            You're welcome.
            – Henrik Schumacher
            3 mins ago










            up vote
            2
            down vote













            ClearAll[aa, nc, dist]
            aa[n_Integer] := Array[x, n];
            nc[n_Integer] := 2^n*Pi^((n - 1)/2)*Gamma[(1 + n)/2]
            dist[n_Integer] := ProbabilityDistribution[Exp[-Norm[aa[n]]]/nc[n],
            ## & @@ Thread[aa[n], -∞, ∞]]

            Expectation[Norm[aa[#]], Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



            2, 3, 4, 5




            Expectation[Norm[aa[#]]^2, Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



            6, 12, 20, 30




            Also:



            td[n_Integer] := TransformedDistribution[Norm[aa[n]], Distributed[aa[n], dist[n]]]

            Mean[td[#]] & /@ Range[2, 5]



            2, 3, 4, 5




            Moment[td[#], 2] & /@ Range[2, 5]



            6, 12, 20, 30




            Variance[td[#]] & /@ Range[2, 5]



            2, 3, 4, 5







            share|improve this answer


























              up vote
              2
              down vote













              ClearAll[aa, nc, dist]
              aa[n_Integer] := Array[x, n];
              nc[n_Integer] := 2^n*Pi^((n - 1)/2)*Gamma[(1 + n)/2]
              dist[n_Integer] := ProbabilityDistribution[Exp[-Norm[aa[n]]]/nc[n],
              ## & @@ Thread[aa[n], -∞, ∞]]

              Expectation[Norm[aa[#]], Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



              2, 3, 4, 5




              Expectation[Norm[aa[#]]^2, Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



              6, 12, 20, 30




              Also:



              td[n_Integer] := TransformedDistribution[Norm[aa[n]], Distributed[aa[n], dist[n]]]

              Mean[td[#]] & /@ Range[2, 5]



              2, 3, 4, 5




              Moment[td[#], 2] & /@ Range[2, 5]



              6, 12, 20, 30




              Variance[td[#]] & /@ Range[2, 5]



              2, 3, 4, 5







              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                ClearAll[aa, nc, dist]
                aa[n_Integer] := Array[x, n];
                nc[n_Integer] := 2^n*Pi^((n - 1)/2)*Gamma[(1 + n)/2]
                dist[n_Integer] := ProbabilityDistribution[Exp[-Norm[aa[n]]]/nc[n],
                ## & @@ Thread[aa[n], -∞, ∞]]

                Expectation[Norm[aa[#]], Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



                2, 3, 4, 5




                Expectation[Norm[aa[#]]^2, Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



                6, 12, 20, 30




                Also:



                td[n_Integer] := TransformedDistribution[Norm[aa[n]], Distributed[aa[n], dist[n]]]

                Mean[td[#]] & /@ Range[2, 5]



                2, 3, 4, 5




                Moment[td[#], 2] & /@ Range[2, 5]



                6, 12, 20, 30




                Variance[td[#]] & /@ Range[2, 5]



                2, 3, 4, 5







                share|improve this answer














                ClearAll[aa, nc, dist]
                aa[n_Integer] := Array[x, n];
                nc[n_Integer] := 2^n*Pi^((n - 1)/2)*Gamma[(1 + n)/2]
                dist[n_Integer] := ProbabilityDistribution[Exp[-Norm[aa[n]]]/nc[n],
                ## & @@ Thread[aa[n], -∞, ∞]]

                Expectation[Norm[aa[#]], Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



                2, 3, 4, 5




                Expectation[Norm[aa[#]]^2, Distributed[aa[#], dist[#]]] & /@ Range[2, 5]



                6, 12, 20, 30




                Also:



                td[n_Integer] := TransformedDistribution[Norm[aa[n]], Distributed[aa[n], dist[n]]]

                Mean[td[#]] & /@ Range[2, 5]



                2, 3, 4, 5




                Moment[td[#], 2] & /@ Range[2, 5]



                6, 12, 20, 30




                Variance[td[#]] & /@ Range[2, 5]



                2, 3, 4, 5








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 7 mins ago

























                answered 18 mins ago









                kglr

                161k8185385




                161k8185385



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182508%2fcalculate-mean-and-variance-of-a-cone-shaped-distribution-in-n-dimensions%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    Installing NextGIS Connect into QGIS 3?

                    One-line joke