ams597 exam

1
# Question 1 rand.vec<-rnorm(60,mean=8,sd=2.5) rand.vec rand.mat<-matrix(rand.vec,nrow=10,ncol=6,byrow=T) rand.mat rand.mat[2,][rand.mat[2,]>10] which(rand.mat[2,]>10) mean(rand.mat[3,]) var(rand.mat[3,]) t.test(rand.mat[1,],rand.mat[2,]) # Question 2 x<-c(height=1.7,weight=6.2,humidity=0.64,temperature=6.4) x y<-c(1,2,4,4,2,1) ylevel<-factor(y,levels=1:4) levels(ylevel)<-c("height","weight","humidity","temperature") ylevel ysubset<-c(as.character(ylevel[1]),as.character(ylevel[2]),as.character(ylevel[4 ])) ysubset z<-matrix(c(y,c(2.3, 4.3, 5.4, 6.5, 3.5, 6.7)),nrow=2,ncol=6,byrow=TRUE) z data.frame(z) # Question 3 vec.x<-rnorm(20) vec.y<-rnorm(20) plot(vec.x,vec.y,main="Simulated vectors X and Y") text(0.2,0.2,"This is the center") value<-list(current=vec.x,future=vec.y) value value$current[value$current>0.15] value$current[value$future>0.15]

Upload: bluue-ou

Post on 12-Jul-2016

215 views

Category:

Documents


1 download

DESCRIPTION

rt

TRANSCRIPT

Page 1: Ams597 Exam

# Question 1

rand.vec<-rnorm(60,mean=8,sd=2.5)rand.vec

rand.mat<-matrix(rand.vec,nrow=10,ncol=6,byrow=T)rand.mat

rand.mat[2,][rand.mat[2,]>10]which(rand.mat[2,]>10)

mean(rand.mat[3,])var(rand.mat[3,])

t.test(rand.mat[1,],rand.mat[2,])

# Question 2

x<-c(height=1.7,weight=6.2,humidity=0.64,temperature=6.4)x

y<-c(1,2,4,4,2,1)ylevel<-factor(y,levels=1:4)levels(ylevel)<-c("height","weight","humidity","temperature")ylevel

ysubset<-c(as.character(ylevel[1]),as.character(ylevel[2]),as.character(ylevel[4]))ysubset

z<-matrix(c(y,c(2.3, 4.3, 5.4, 6.5, 3.5, 6.7)),nrow=2,ncol=6,byrow=TRUE)z

data.frame(z)

# Question 3

vec.x<-rnorm(20)vec.y<-rnorm(20)plot(vec.x,vec.y,main="Simulated vectors X and Y")

text(0.2,0.2,"This is the center")

value<-list(current=vec.x,future=vec.y)value

value$current[value$current>0.15]

value$current[value$future>0.15]