data(morley)
head(morley)
morley$Speed
x=morley$Speed
hist(x)
boxplot(x)
boxplot(xh=T)
boxplot(x,h=T)
boxplot(x,horizontal=T)
qnorm(0.975)
qt(0.975,99)
qt(0.975,1:29)
x
mean(x)+c(-1,1)*2*sd(x)/sqrt(length(x))
mean(x)+c(-1,1)*qt(0.975,length(x)-1)*sd(x)/sqrt(length(x))
mean(x)+c(-1,1)*qnorm(0.975)*sd(x)/sqrt(length(x))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,1],c(0.025,0.975))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,1],c(0.025,0.975))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,1],c(0.025,0.975))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,1],c(0.025,0.975))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,1],c(0.005,0.995))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,1],c(0.005,0.995))
mean(x)+c(-1,1)*qt(0.995,length(x)-1)*sd(x)/sqrt(length(x))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,2],c(0.025,0.975))
sd(x)
mean(x)+c(-1,1)*qt(0.975,length(x)-1)*sd(x)/sqrt(length(x))
mean(x)
qt(0.975,length(x)-1)*sd(x)/sqrt(length(x))
2*80^2/10^2
4*80^2/10^2
n=10
p=0.5
x=0:n
plot(dbinom(x,p))
n=10
p=0.5
x=0:n
plot(dbinom(x,prob=p))
n=10
p=0.5
x=0:n
plot(dbinom(x,size=n,prob=p))
n=10
p=0.5
x=0:n
plot(dbinom(x,size=n,prob=p))
n=100
p=0.5
x=0:n
plot(dbinom(x,size=n,prob=p))
n=100
p=0.1
x=0:n
plot(dbinom(x,size=n,prob=p))
n=100
p=0.01
x=0:n
plot(dbinom(x,size=n,prob=p))
n=1000
p=0.01
x=0:n
plot(dbinom(x,size=n,prob=p))
n=1000
p=0.01
x=0:n/4
plot(dbinom(x,size=n,prob=p))
n=1000
p=0.01
x=0:(n/4)
plot(dbinom(x,size=n,prob=p))
1/.05^2
1/.01^2
5280-qt(0.99,6)*375/sqrt(7)
bsim
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,2],c(0.025,0.975))
sd(x)
sd(morley$Speed)
s=sd(morley$Speed)
s
length(morley$Speed)
99*s^2/qchisq(0.975,99)
99*s^2/qchisq(0.025,99)
c(99*s^2/qchisq(0.975,99),99*s^2/qchisq(0.025,99))
sqrt(c(99*s^2/qchisq(0.975,99),99*s^2/qchisq(0.025,99)))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,2],c(0.025,0.975))
bsim=NULL
for(i in 1:1000){
bsd=sample(morley$Speed,replace = T, size=100)
bsim=rbind(bsim,c(mean(bsd),sd(bsd)))
}
quantile(bsim[,2],c(0.025,0.975))
savehistory("N:/321_su19_data/20190612_in_class.Rhistory")
