# runif_ellipsoid: Uniform sampling on/in ellipsoid In stla/uniformly: Uniform Sampling

## Description

Uniform sampling on an ellipsoid or in an ellipsoid (arbitrary dimension).

## Usage

 ```1 2 3``` ```runif_on_ellipsoid(n, A, r) runif_in_ellipsoid(n, A, r) ```

## Arguments

 `n` number of simulations `A` symmetric positive-definite matrix defining the ellipsoid (see Details) `r` "radius" (see Details)

## Details

The ellipsoid is the set of vectors `x` satisfying `t(x) %*% A %*% x == r^2`.

## Value

The simulations in a matrix with `n` rows.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```A <- rbind(c(2,1),c(1,1)) r <- 2 sims <- runif_on_ellipsoid(30, A, r) plot(sims, xlim=c(-2,2), ylim=c(-3,3), asp=1, pch=19) sims <- runif_in_ellipsoid(100, A, r) plot(sims, xlim=c(-2,2), ylim=c(-3,3), asp=1, pch=19) # 3D example A <- matrix(c(5,1,1, 1,3,1, 1,1,1), ncol=3) r <- 2 # draw the ellipsoid library(misc3d) x <- seq(-1, 1, len=50) y <- seq(-1.5, 1.5, len=50) z <- seq(-2.7, 2.7, len=50) g <- as.matrix(expand.grid(x=x, y=y, z=z)) voxel <- array(apply(g, 1, function(v) t(v) %*% A %*% v), dim=c(50,50,50)) isosurface <- computeContour3d(voxel, max(voxel), r^2, x=x, y=y, z=z) drawScene.rgl(makeTriangles(isosurface, alpha=0.3)) # simulate and plot points on ellispoid library(rgl) sims <- runif_on_ellipsoid(200, A, r) points3d(sims) ```

stla/uniformly documentation built on Aug. 10, 2018, 7:03 a.m.