Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Bootstrap for Gaussian Distribution
set.seed(5610) x <- rnorm(300,10,15) bootstrap <- function(B,data){ sam = B dat = data n = length(data) mean.vector = c() for( i in 1:sam){ a = sample(dat,n,replace = T) mean.vector[i] = mean(a) } m.est = mean(mean.vector) # Mean estimate of samples var.est = var(mean.vector) # Variance estimate of samples # Histogram hist(mean.vector,col = 'gray50',freq = F,border = 'white', ylim = c(0,1), xlab = "Sample Mean",main = "Histogram of Sample Mean", cex.main = 0.8, breaks = 45) # Density estimate curve(dnorm(x,m.est,var.est), add = TRUE, lwd = 2, col = "red3") # maximum is (sigma*sqrt(2*pi))^(-1); use sigma_est = var.est max = (var.est*sqrt(2*pi))^(-1) points(m.est, max, col = "red3", pch = 19) # Line of mean estimate segments(m.est,0,m.est,max,col = 'blue',lty = 2, lwd = 2, pch = 19) cat("\n The mean estimate is: ", mean(mean.vector)) cat("\n The variance estimate is: ", var(mean.vector)) cat("\n Standard error: ", sqrt(var(mean.vector))) } mean(x) bootstrap(100000,x)
run
|
edit
|
history
|
help
0
Ex15-12-20
Paired t-test [Access Medical Information]
stats and fats survey histograms
factorial code
Sign test
Erro padrão
taylorsen7
Guess the next number
code
First wall