0
$\begingroup$

Inspired by this question I try to find to compute the variance of: $$f(\vec{t}) = \cases{\frac{d + 2}{2 c_d}(1 - \vec{t} \cdot \vec{t}) & if $\vec{t} \cdot \vec{t}< 1$ \\0 & otherwise}$$

where $c_d$ is the volume of the unit sphere of dimension $d$:

$$ c_d = \frac{\pi^{d/2}}{\Gamma\left(\frac{d}{2} + 1\right)},$$ according to: $$E[x] = \int_{-\infty}^{\infty} x \cdot f(x) \; dx$$ and $$VAR[x]= E[x^2] - \left(E[x]\right)^2.$$

I tried to do this with the following mathematica code

$Assumptions = {d >= 1, Element[d, Integers], Element[x, Vectors[d]]};
unitSphereVolume  = pi^(d/2)/Gamma[d/2 + 1];

epan [t_] = Piecewise[{{(d + 2)/(2 * unitSphereVolume) (1 - Dot[t, t]), Dot[t, t] < 1}}, 0];

EV[_t] = Refine[D[t * epan[t], t], Element[t, Vectors[d]]];
V[_t] = Refine[EV[t^2] - (EV[t])^2, Element[t, Vectors[d]]];
FunctionExpand[V[x]]

I want to compute the variance of $f(x)$ as a function of $d$, but evaluating this notebooks gives V[x] as output. What am I missing?

$\endgroup$
1
  • $\begingroup$ Your question may be put on-hold as it seems to be off-topic, i.e it arises from a simple mistake (syntax error, incorrect capitalization, spelling mistake) and is unlikely to help any future visitors, or else it is easily found in the documentation. Don't be discouraged by that cleaning-up policy. Your future good questions are welcome. Learn about common pitfalls here. $\endgroup$
    – rhermans
    Commented May 15, 2017 at 12:50

1 Answer 1

3
$\begingroup$

Change [_t] to [t_], pi to Pi

$Assumptions = {d >= 1, Element[d, Integers], Element[x, Vectors[d]]};
unitSphereVolume = Pi^(d/2)/Gamma[d/2 + 1];

epan[t_] = 
  Piecewise[{{(d + 2)/(2*unitSphereVolume) (1 - Dot[t, t]), 
     Dot[t, t] < 1}}, 0];

EV[t_] = Refine[D[t*epan[t], t], Element[t, Vectors[d]]];
V[t_] = Refine[EV[t^2] - (EV[t])^2, Element[t, Vectors[d]]];

FullSimplify@PiecewiseExpand@V[x]

Mathematica graphics

$\endgroup$
0

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