-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource_arima.R
More file actions
55 lines (49 loc) · 1.23 KB
/
Copy pathsource_arima.R
File metadata and controls
55 lines (49 loc) · 1.23 KB
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
library(R6)
Source <- R6Class(
"Source",
public = list(
N = NULL,
i = NULL,
df = list(),
initialize = function(N = 3000) {
self$N <- as.numeric(N)
self$i <- 0
self$df$x <- as.numeric(arima.sim(
model = list(
ar = c(0.8897, -0.4858),
ma = c(-0.2279, 0.2488),
order = c(2, 1, 2)
),
n = self$N
))
self$df$y <- as.numeric(arima.sim(
model = list(
ar = c(0.8897, -0.4858),
ma = c(-0.2279, 0.2488),
order = c(2, 1, 2)
),
n = self$N
))
self$df$z <- as.numeric(arima.sim(
model = list(
ar = c(0.8897, -0.4858),
ma = c(-0.2279, 0.2488),
order = c(2, 1, 2)
),
n = self$N
))
},
current_data = function() {
self$i <- self$i + 1
if (self$i > self$N) self$i <- 1
point = c(self$df$x[self$i], self$df$y[self$i], self$df$z[self$i])
list("arima" = list("i" = self$i, "x" = point[1], "y" = point[2], "z" = point[3], "point" = point), return_type="success")
}
)
)
arima <- Source$new(3000)
set_params <- function(params) {
print(params)
}
# Entry point
get_output <- function() arima$current_data()