/
ts_mapping.R
99 lines (81 loc) · 2.37 KB
/
ts_mapping.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#############################################################
################### TIME SERIES MAPPINGS ####################
#############################################################
#######################################################
#### load time series mapping algorithms
source("vg_algorithm.R")
source("qg_algorithm.R")
#######################################################
#### Auxiliary functions to call respective mapping
#### algorithm
## Main function to generate all visibility and quantile
# graphs.
# Function to time series set stored in matrix format.
# Mapping default is unweighted NVG.
generate_Graphs <- function(timeseries, inst_numb, length, q = 0, map_type = "NVG", weight_type = FALSE, is_Markov = FALSE) {
graph <- list()
total_g <- 1
## (W)NVG
if(map_type == "NVG") {
for(i in 1:inst_numb) {
graph[[i]] <- NVG(timeseries[, i], length, weight_type)
total_g <- total_g + 1
}
}
## (W)HVG
else if(map_type == "HVG") {
for(i in 1:inst_numb) {
graph[[i]] <- HVG(timeseries[, i], length, weight_type)
total_g <- total_g + 1
}
}
## QG
else if (map_type == "QG") {
for(i in 1:inst_numb) {
graph[[i]] <- QG(timeseries[, i], length, q, is_Markov)
total_g <- total_g + 1
}
}
else {
cat("ERROR: no mapping method")
return()
}
return(graph)
}
## Main function to generate all visibility and quantile
# graphs.
# Function to time series set stored in list format.
# Mapping default is unweighted NVG.
generate_Graphs_list <- function(timeseries, inst_numb, q = 0, map_type = "NVG", weight_type = FALSE, is_Markov = FALSE) {
graph <- list()
total_g <- 1
## (W)NVG
if(map_type == "NVG") {
for(i in 1:inst_numb) {
length <- length(timeseries[[i]])
graph[[i]] <- NVG(timeseries[[i]], length, weight_type)
total_g <- total_g + 1
}
}
## (W)HVG
else if(map_type == "HVG") {
for(i in 1:inst_numb) {
length <- length(timeseries[[i]])
graph[[i]] <- HVG(timeseries[[i]], length, weight_type)
total_g <- total_g + 1
}
}
## QG
else if (map_type == "QG") {
for(i in 1:inst_numb) {
length <- length(timeseries[[i]])
graph[[i]] <- QG(timeseries[[i]], length, q, is_Markov)
total_g <- total_g + 1
}
}
else {
cat("ERROR: no mapping method")
return()
}
return(graph)
}