Matma_AI_cyber/Projekt_1/Bootstrapping.R

27 lines
534 B
R
Raw Permalink Normal View History

2022-04-27 12:37:59 +02:00
#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))
2022-05-10 17:26:35 +02:00
hist(Wynik,prob=T,main='normal')
hist(bootstrappedData,prob=T,main='bootstrapped')
2022-05-08 23:55:40 +02:00
2022-05-10 17:26:35 +02:00
par(mfrow=c(1,2))
boxplot(Wynik,prob=T,main='normal')
boxplot(bootstrappedData,prob=T,main='bootstrapped')
2022-05-08 23:55:40 +02:00