Calculate mean and variance of a cone-shaped distribution in N-dimensions
Clash 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,
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
add a comment |Â
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,
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
add a comment |Â
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,
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
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,
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
numerical-integration probability-or-statistics geometry
asked 46 mins ago
ben18785
1,351622
1,351622
add a comment |Â
add a comment |Â
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
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
add a comment |Â
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited 7 mins ago
answered 18 mins ago
kglr
161k8185385
161k8185385
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password