-
Notifications
You must be signed in to change notification settings - Fork 2
/
one_class_stats.r
53 lines (42 loc) · 1.14 KB
/
one_class_stats.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
50
51
52
library(diptest)
library(nortest)
library(moments)
#library(bimodalitytest)
analyse_class <- function(filename){
dat = read.csv(filename, header=FALSE, skip=1)
x = dat$V1
dip_res = dip.test(x)
shapiro_res = shapiro.test(x)
ad_res = ad.test(x)
#bimt = bimodality.test(x)
results = numeric()
results[1] = length(x)
results[2] = mean(x)
results[3] = sd(x)
results[4] = kurtosis(x)
results[5] = skewness(x)
results[6] = dip_res[1]
results[7] = dip_res[2]
results[8] = shapiro_res[1]
results[9] = shapiro_res[2]
results[10] = ad_res[1]
results[11] = ad_res[2]
results[12] = 0#bimt@p_value
results[13] = 0#bimt@LR
ldat = log(dat)
#print(ldat)
lx = ldat$V1
shapiro_lres = shapiro.test(lx)
results[14] = shapiro_lres[1]
results[15] = shapiro_lres[2]
print(results)
return(results)
}
args <- commandArgs(trailingOnly = TRUE)
filestance = args[1]#"grades_2012w_4.csv"
filename = paste(filestance,sep="/")
sink = paste("r_output",filestance,sep="/")
res = analyse_class(filename)
res = t(res)
#save(res, file = sink, ascii=TRUE)
write.table(res, file = sink, sep=",", eol="\n", row.names=FALSE, col.names=FALSE)