Generating samples within a sphere according to a specified distribution

80 Views Asked by At

Let's consider a ball in $\mathbb{R}^n$ centered at some point $x$ with radius $r$. I am interested in generating samples (random points) within this ball. It is well known that, according to sources such as link, using Gaussian random variables and normalizing them produces random points that are uniformly distributed within a sphere.

Now let's say I want to generate random points within this ball according to a specified distribution. Are there general procedures for doing this? Or, are there other known specific approaches that produce specific distributions within the ball?

1

There are 1 best solutions below

1
On

If you can generate random samples uniformly distributed within the $n$-dimensional sphere then you can generate other distributions by the rejection sampling method.

Here, I am going to describe the above mentioned method if the $n$-dimensional density, $f$ exists and is bounded by, say, $B$ inside the sphere. (It is zero outside the same.)

Now, let your uniformly distributed samples denoted by $\{\vec X_n\}$. Take independent random numbers, $\{Y_n\}$ uniformly distributed over $[0,B]$. Then take the sample of the pairs: $\{(\vec X_n, Y_n)\}$.

Accept $\vec X_n$ if $$f(\vec X_n)\leq B_n$$ reject it otherwise. The distribution of the accepted samples will be of $f$.