Matma_AI_cyber/Projekt_1/Bootstrapping.R
2022-05-10 17:26:35 +02:00

27 lines
534 B
R

#Bootstrap
load("Hamulce.RData")
attach(Hamulce)
ourBoot <- function(data, outSize, sampleSize) {
output <- c()
for (i in 1:outSize) {
sampleElements <- sample(data, sampleSize, replace=TRUE)
output <- append(output, mean(sampleElements))
}
return(output)
}
bootstrappedData <- ourBoot(Wynik, 200, 50)
par(mfrow=c(1,2))
hist(Wynik,prob=T,main='normal')
hist(bootstrappedData,prob=T,main='bootstrapped')
par(mfrow=c(1,2))
boxplot(Wynik,prob=T,main='normal')
boxplot(bootstrappedData,prob=T,main='bootstrapped')