swh:1:snp:ffdd0a7d2c8ea15ad41d45b3b178f668bd942287
Tip revision: 132ff3b511872d504d88a6b35e26ac4652fcf5ed authored by Derek Young on 01 May 2007, 00:00:00 UTC
version 0.2.0
version 0.2.0
Tip revision: 132ff3b
ellipse.r
ellipse <- function(mu, sigma, alpha=.05, npoints=250,
newplot=FALSE, draw=TRUE, ...) {
es <- eigen(sigma)
e1 <- es$vec%*%diag(sqrt(es$val))
r1 <- sqrt(qchisq(1-alpha,2))
theta <- seq(0,2*pi,len=npoints)
v1 <- cbind(r1*cos(theta),r1*sin(theta))
pts=t(mu-(e1%*%t(v1)))
if (newplot && draw) {
plot(pts, ...)
} else if (!newplot && draw) {
lines(pts, ...)
}
invisible(pts)
}