This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new.range <- function(x, new.min=0, new.max=1){ | |
ranx <- range(x, na.rm=TRUE) | |
px <- (x-ranx[1])/(ranx[2]-ranx[1]) | |
res <- new.min+((new.max-new.min)*px) | |
res | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###pca - calculated for the first 4 columns of the data set that correspond to biometric measurements ("Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width") | |
data(iris) | |
dat <- as.matrix(iris[,-5]) | |
pca <- prcomp(dat, retx=TRUE, center=TRUE, scale=TRUE) | |
###Create new data sets for each of the three species. | |
#Biometric values are based on the distributions of the original data means | |
#and the covariances between these parameters. | |
setosa.mean <- apply(iris[iris$Species=="setosa",-5], 2, mean) | |
setosa.cov <- cov(iris[iris$Species=="setosa",-5]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mu <- 5 | |
sigma <- 2 | |
vals <- seq(-2,12,,100) | |
ds <- dnorm(vals, mean=mu, sd=sigma) | |
plot(vals, ds, t="l") | |
qs <- qnorm(c(0.05, 0.95), mean=mu, sd=sigma) | |
abline(v=qs, col=2, lty=2) | |
NewerOlder