[R] random uniform sample of points on an ellipsoid (e.g. WG

Alberto Monteiro albmont at centroin.com.br
Thu Mar 1 15:17:07 CET 2007


R Heberto Ghezzo, Dr wrote:
>
> I do not know if I am completely out of it but . . .
> if x,y,z is a point in a sphere and [u,v,w]'A[u,v,w] = 1 is the 
> equation of an ellipsoid and A = T'T (cholesky) then
> T.[x,y,z] should be a point in the ellipsoid ? isn't it? 
>
Yes, it's a point _on_ the ellipsoid, but it's not "uniformly"
distributed over the ellipsoid. The easy part is generating 
points on the ellipsoid, the hard part is generating them
uniformly.

For example, imagine a very flat ellipsoid, so flat that it's
almost a disk. Then A is something like the diagonal matrix
diag(c(1, 1, 0.0001)), T (let's call it Chol) is diag(c(1,1,0.01)), 
and a plot of Chol.[x,y,z] will look like this:

v <- cbind(rnorm(1000), rnorm(1000), rnorm(1000))
# there may be a better way to write the expression below:
v <- v / sqrt(v[,1]^2 + v[,2]^2 + v[,3]^2)
# now v is uniformly distributed over the sphere
Chol <- diag(c(1, 1, 0.01))
ep <- v %*% t(Chol)
plot(ep[,1], ep[,2])

with a clear trend to generate points closer to the equator
then in the polar regions, against the assumption that they
should be uniformly distributed over the surface of the
ellipsoid.

Alberto Monteiro



More information about the R-help mailing list