2

How to pick random uniformly distributed points in a sphere has been asked before. The difference is that I don't want uniform distribution, rather I would like the number density to scale by $r^{-1}$.

The only method I can think of is to generate random x, y and z coordinates, reject those that are outside the sphere and then do another test. For simplicity I chose to distribute points between radius 1 and the sphere's radius R, with these values I calculated a probability function $p(r)=\frac{1}{\rm{ln}(R)r}$. The test was that I generated another random number and rejected the point if that number was larger than p(r). However I don't know if this is correct, and I'm hoping for a better idea since it was very slow for large R.

  • So you want to generate points that are at distance from $1$ to $R$ from the origin? Thus not in the ball, but in part of the ball? As you know, there is no probability distribution with proportionality to $1/r$ in the whole ball. – André Nicolas Apr 15 '14 at 18:32

1 Answers1

0

If you look at the accepted answer for the post you linked, you see that the direction is generated by sampling from a multivariate normal distribution, and then the radius is chosen according to the desired distribution. In your case, you don't need to define a minimal radius $R_0 > 0$ because when you multiply the scaling factor $1/r$ for probability of the radius by the surface area of the sphere $\Theta(r^2)$ you get $\Theta(r)$, and so you have $P(r \leq R) \propto \int_{0}^R (1/r)r^2 dr = \Theta(R^2)$ where you have a maximum radius $R_{max}$. This gives you your cdf (cumulative distribution function ) of $f(R) = P(r \leq R) = R^2/R_{max}^2$ for sampling the radius. The inverse of the cumulative distribution function is $g(X) = R_{max} \sqrt{X}$. If you sample a uniform random variable $X$ from $[0,1]$ and compute $r = g(X)$, this gives you the desired distribution on the radius $r$ that has cumulative distribution function $f(R)$. See http://en.wikipedia.org/wiki/Inverse_transform_sampling for an explanation on inverse transform sampling.

user2566092
  • 26,142
  • I'm afraid I am very weak in statistics. I can't see how to go from the linked answer and this to a function that will generate points. I can generate random direction, but could you provide more details on the radius? –  Apr 15 '14 at 19:48
  • @Pickett I added more detailed formulas and explanation, with a link on inverse transform sampling that is used to generate radius with the desired distribution. Note I am assuming you have a $1/r$ multiplier on the density, instead of uniform constant. This is different from saying that the density on radius is $1/r$. If you want to use $P(r) \propto 1/r$ then integrate from your min radius to $R$, and divide by what you get when you plug in the max radius. You'll get $f(R) = (\ln R - \ln R_{min})/(\ln R_{max} - \ln R_{min})$. Invert $f$ (solve for $R$) to get $g(X)$ and proceed as before. – user2566092 Apr 16 '14 at 14:23