-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathglobal.R
More file actions
27 lines (23 loc) · 742 Bytes
/
global.R
File metadata and controls
27 lines (23 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
generator = function(n = 100, pop.mean = 0, pop.sd = 1, conf.lvl = .95) {
plot(NULL
,xlim = c(pop.mean-pop.sd,pop.mean+pop.sd)
,ylim = c(0,100)
,yaxt = 'n'
,xlab = (conf.lvl)
,ylab = (n)
# ,main = "Confidence Intervals of 100 Samples"
)
abline(v = pop.mean, col = 'black')
mtext(expression(mu), cex = 2, at = pop.mean)
for (i in 1:100){
x <- rnorm(n, mean = pop.mean, sd = pop.sd)
test <- t.test(x,conf.level=conf.lvl)
interval <- test$conf.int
if(pop.mean>interval[1] & pop.mean<interval[2]){
lines(c(interval[1],interval[2]),c(i,i), lwd=2,col='black')
}
else{
lines(c(interval[1],interval[2]),c(i,i), lwd=2,col='red' )
}
}
}