Skip to content

Commit

Permalink
first commit of ellipse, added from the mixtools package (which is be…
Browse files Browse the repository at this point in the history
…ing decommissioned).
  • Loading branch information
drammock committed Mar 25, 2013
1 parent beb5dc7 commit 60e3e7f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions phonR/R/ellipse.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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)
}


0 comments on commit 60e3e7f

Please sign in to comment.