Seeing your region of integration is a unit sphere, I suspect you can go over to spherical coordinates. If you have a uniform distribution inside a sphere of radius R, i.e. if the distribution is:
<br />
\varphi(x, y, z) = \frac{3}{4 \, \pi \, R^{3}} \, \Theta(R - \sqrt{x^{2} + y^{2} + z^{2}})<br />
where
<br />
\Theta(x) = \left\{\begin{array}{l}{1, \; x \ge 0 \\ 0, \; x < 0 \end{array}\right.<br />
is the Heaviside step function and you know the Jacobian to be:
<br />
J = \frac{\partial(x, y, z)}{\partial(r, \theta, \phi)} = r^{2} \, \sin{\theta} \, dr \, d\theta \, d\phi<br />
then:
<br />
\varphi(x,y,z) \, dx \, dy \, dz = \tilde{\varphi}(r, \theta, \phi) dr \, d\theta \, d\phi<br />
and you express everything in spherical coordinates, you will get:
<br />
\tilde{\varphi}(r, \theta, \phi) = \frac{3}{R^{3}} \theta(R - r) \, r^{2} \, \frac{1}{2} \, \sin{\theta} \, \frac{1}{2 \pi}<br />
You can see that this distribution function factors out into products of function which depend on a single variable. This means you can obtain the same distribution (uniform inside a sphere of radius R) if you generate two one-dimensional random variables with the following distributions:
1. \varphi_{1}(\phi) = \frac{1}{2 \, \pi}, \; 0 \le \phi \le 2 \pi;
2. \varphi_{2}(\theta) = \frac{1}{2} \, \sin{\theta}, \; 0 \le \theta \pi;
3. \varphi_{3}(r) = \frac{3 r^{2}}{R^{3}}, \; 0 \le r \le R
and, once you have a particular sample (r_{0}, \theta_{0}, \phi_{0})[/tex], then you can <b> calculate</b> the Cartesian coordinates:<br />
<br />
<br />
x_{0} = r_{0} \, \sin{\theta_{0}} \, \cos{\phi_{0}}<br /><br />
<br />
y_{0} = r_{0} \, \sin{\theta_{0}} \, \sin{\phi_{0}}<br /><br />
<br />
z_{0} = r_{0} \, \cos{\theta_{0}}<br /><br />
<br />
It is guaranteed that the sample of points (x_{0}, y_{0}, z_{0}) is uniformly distributed inside the sphere of radius <i>R</i>.<br />
<br />
The advantage that this method has is that there are no points that are no sample points being rejected. The ratio of the volumes of a sphere with radius <i>R</i> and a cube with side 2<i>R</i> (so that the sphere lies wholly inside the cube) is:<br />
<br />
<br />
\frac{\frac{4 \, \pi \, R^{3}}{3}}{(2 \, R)^{3}} = \frac{\pi}{6} = 0.52<br /><br />
<br />
so, by simply rejecting points, you will need to generate approximately twice as many as you need.<br />
<br />
The disadvantage is that you need generate random variables with non-uniform distribution. Fortunately, the distributions are elementary and you can use the following Theorem:<br />
<br />
If f(x), \alpha \le x \le \beta is a continuous function that represents the probability distribution function of a random variable <i>X</i> then:<br />
<br />
<br />
dY = f(X) dX \Rightarrow Y = F(X) = \int_{\alpha}^{x}{f(t) \, dt}, \alpha \le x \le \beta<br /><br />
<br />
the random variable <i>Y</i> has uniform distribution on the segment [0, 1]. If you can invert this relationship:<br />
<br />
<br />
X = F^{-1}(Y), 0 \le y \le 1<br /><br />
<br />
and you generate a uniformly distributed random variable, then <i>X</i> will have the PDF required. In our case:<br />
<br />
<br />
Y = \int_{0}^{r}{\frac{3 x^{2}}{R^{3}} \, dx} = \left(\frac{r}{R}\right)^{3} \Rightarrow r = R \, Y^{1/3}<br /><br />
<br />
<br />
Z = \int_{0}^{\theta}{\frac{\sin{t} \, dt}{2}} = -\left.\frac{\cos{t}}{2}\right|^{\theta}_{0} = \frac{1 - \cos{\theta}}{2} = \sin^{2}{\frac{\theta}{2}} \Rightarrow \theta = 2 \, \arcsin{Z^{1/2}}<br /><br />
<br />
These formula furnish the whole algorithm for generating points uniformly inside a sphere of radius <i>R</i>. Notice, however, that Monte Carlo is much more efficient if the points are generated with a distribution that is comparable to the values of the integrand.