### Content

# 共通変数および関数
set.seed(20190102)
population_size <- 10^3;sample_size <- 50;repetition <- 1000
fun_sampling_and_calculate_average <- function(population,sample_size,repetition){
return(sapply(seq(repetition),function(x)mean(sample(x = population,size = sample_size))))
}

Uniform distribution
population <- runif(n = population_size,min = 1,max = 100)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.016695, p-value = 0.9388
alternative hypothesis: two-sided

Beta distribution
population <- rbeta(n = population_size,shape1 = 2,shape2 = 5)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.020971, p-value = 0.7631
alternative hypothesis: two-sided

Gamma distribution
population <- rgamma(n = population_size,shape = 5,rate = 0.1)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.020201, p-value = 0.8013
alternative hypothesis: two-sided

Cauchy distribution(『the mean or variance are not defined』(Wikipedia))
population <- rcauchy(n = population_size,location = 0,scale = 0.5)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.17095, p-value = 6.106e-15
alternative hypothesis: two-sided

Logistic distribution
population <- rlogis(n = population_size,location = 3,scale = 2)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.019521, p-value = 0.8332
alternative hypothesis: two-sided

Poisson distribution
population <- rpois(n = population_size,lambda = 3)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.032932, p-value = 0.2233
alternative hypothesis: two-sided

Weibull distribution
population <- rweibull(n = population_size,shape = 3,scale = 3)
averages <- fun_sampling_and_calculate_average(population = population,sample_size = sample_size,repetition = repetition)
ks.test(x = averages,y = 'pnorm',mean = mean(averages),sd = sd(averages),exact = T)

One-sample Kolmogorov-Smirnov test

data:  averages
D = 0.016849, p-value = 0.9344
alternative hypothesis: two-sided