-
Notifications
You must be signed in to change notification settings - Fork 0
/
pso_ga_result_analysis.R
54 lines (32 loc) · 1.36 KB
/
pso_ga_result_analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
library(dplyr)
setwd("/Users/aytacozkan/works/heuristic.space.maximization/csv/")
ga_fname = "GA/Results/GA_Results_1555372486.csv"
pso_fname = "PSO/Results/PSO_Results_1555431041.csv"
ga_set <- scan(ga_fname, sep = ",", what = numeric(0), quiet = TRUE)
pso_set <- scan(pso_fname, sep = ",", what = numeric(0),quiet = TRUE)
compare_them <- function(ga_data,pso_data) {
ga_sum <- summary(ga_data)
pso_sum <- summary(pso_data)
t.value1 = (mean(ga_data) - 10) / (sd(ga_data) / sqrt(length(ga_data)))
p.value1 = dt(t.value1, df=length(ga_data) - 1)
t.value2 = (mean(pso_data) - 10) / (sd(pso_data) / sqrt(length(pso_data)))
p.value2 = dt(t.value2, df=length(pso_data) - 1)
ga_sum$t.value = t.value1
ga_sum$p.value = p.value1
pso_sum$t.value = t.value2
pso_sum$p.value = p.value2
names(ga_sum) <- paste0(names(ga_sum),"1")
names(pso_sum) <- paste0(names(pso_sum),"2")
final <- cbind(ga_sum,pso_sum)
final1 <- t(final)
final2 <- final1[order(row.names(final1)), ]
final_1 <- t(final2) %>% data.frame()
final_1
}
compare_them(ga_set,pso_set) %>% View()
polygon = c(c(10,10),c(10,300),c(250,300),c(350,130),c(200,10))
# Student t-Test
t.test(x=ga_set, mu=10, conf.level=0.95)
# Manually calculate p-value
t.value = (mean(polygon) - 10) / (sd(polygon) / sqrt(length(polygon)))
p.value = dt(t.value, df=length(polygon) - 1)