Uniform sampling on an ellipsoid or in an ellipsoid. The sampling in an ellipsoid is available in arbitrary dimension. The sampling on an ellipsoid is available only in dimension 2 or 3. This code is borrowed directly from the uniformly package (https://CRAN.R-project.org/package=uniformly)
runif_on_ellipse(n, A, r)runif_on_ellipsoid(n, A, r)
runif_in_ellipsoid(n, A, r)
The simulations in a matrix with n rows.
number of simulations
symmetric positive-definite matrix defining the ellipsoid (see
Details), of size 2 for runif_on_ellipse and size 2 or 3 for
runif_on_ellipsoid (for size 2 these are the same functions)
"radius" (see Details)
The ellipsoid is the set of vectors x satisfying
t(x) %*% A %*% x == r^2. For example, for an axis-aligned
ellipse with horizontal radius a and vertical radius b, take
A=1/diag(c(a^2,b^2)) and r=1.