Matma_AI_cyber/Projekt_1/Bootstrapping.R
2022-05-08 23:55:40 +02:00

26 lines
411 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='')
hist(bootstrappedData,prob=T,main='')