### Uniform distribution

population_size <- 10^5
sample_size <- 300
repetition <- 1000
population <- runif(n = population_size,min = 1,max = 100)
fun_mean_sd <- function(population,sample_size){
sample_extract <- sample(x = population,size = sample_size)
return(mean(sample_extract))
}
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Uniform distribution. Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
50.44899 1.650356 50.44721 1.652943

### Beta distribution

population <- rbeta(n = population_size,shape1 = 2,shape2 = 5)
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Beta distribution. Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
0.2855223 0.00919 0.2855901 0.0092384

### Gamma distribution

population <- rgamma(n = population_size,shape = 5,rate = 0.1)
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Gamma distribution. Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
50.02844 1.334002 50.02503 1.292568

### Cauchy distribution(『the mean or variance are not defined』(Wikipedia))

population <- rcauchy(n = population_size,location = 0,scale = 0.5)
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Cauchy distribution(『the mean or variance are not defined』(Wikipedia)). Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
0.3827181 8.474122 0.3182191 8.559554

### Logistic distribution

population <- rlogis(n = population_size,location = 3,scale = 2)
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Logistic distribution. Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
3.011479 0.2083975 2.998957 0.2087975

### Poisson distribution

population <- rpois(n = population_size,lambda = 3)
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Poisson distribution. Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
2.991593 0.0988098 2.9936 0.0995612

### Weibull distribution

population <- rweibull(n = population_size,shape = 3,scale = 3)
random_sample <- sapply(seq(repetition),function(x)fun_mean_sd(population = population,sample_size = sample_size))
Weibull distribution. Population:100000,Sample size:300,Repetition:1000
mean(random_sample) sd(random_sample) mean(population) sd(population)/sample_size^0.5
2.687396 0.0572834 2.685695 0.0562887