Learn R Programming

norMmix (version 0.2-0)

ellipsePts: Compute Points on Bivariate Gaussian Confidence Ellipse

Description

From 2-dimensional mean vector mu\(= \mu\) and 2x2 covariance matrix sigma\(= \Sigma\), compute npoints equi-angular points on the 1-alpha\( = 1-\alpha\) confidence ellipse of bivariate Gaussian (normal) distribution \(\mathcal{N}_2(\mu,\Sigma)\).

Usage

ellipsePts(mu, sigma, npoints, alpha = 0.05, r = sqrt(qchisq(1 - alpha, df = 2)))

Value

a numeric matrix of dimension npoints x 2, containing the x-y-coordinates of the ellipse points.

Arguments

mu

mean vector (numeric of length 2).

sigma

2x2 matrix, the covariance matrix.

npoints

integer specifying the number of points to be computed.

alpha

confidence level such that the ellipse should contain 1-alpha of the mass.

r

radius of the ellipse, typically computed from alpha, via the default value.

Author

Martin Maechler

Examples

Run this code
xy <- ellipsePts(c(10, 100), sigma = cbind(c(4, 7), c(7, 28)),  npoints = 20)
plot(xy, type = "b", col=2, cex=2,
     main="ellipsePts(mu = (10,100), sigma, npoints = 20)")
points(10, 100, col=3, cex=3, pch=3)
text  (10, 100, col=3, expression(mu == "mu"), adj=c(-.1, -.1))

stopifnot(is.matrix(xy), dim(xy) == c(20, 2))

Run the code above in your browser using DataLab