-
Notifications
You must be signed in to change notification settings - Fork 9
/
speedtest.R
82 lines (73 loc) · 2.85 KB
/
speedtest.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
zz <- file("speedtest_output.txt", open = "wt")
sink(zz)
sink(zz, type = "message")
cat("#####\n", date(), "\n")
sessionInfo()
cat("### Some benchmark tests ###\nSource: https://mac.r-project.org/benchmarks/bench.R\n\nBEGIN\n")
# BEGIN benchmark tests
hilbert<-function(n) 1/(outer(seq(n),seq(n),"+")-1)
print("hilbert n=500")
print(system.time(eigen(hilbert(500))))
print(system.time(eigen(hilbert(500))))
print(system.time(eigen(hilbert(500))))
print("hilbert n=1000")
print(system.time(eigen(hilbert(1000))))
print(system.time(eigen(hilbert(1000))))
print(system.time(eigen(hilbert(1000))))
print("sort n=6")
print(system.time(sort(rnorm(10^6))))
print(system.time(sort(rnorm(10^6))))
print(system.time(sort(rnorm(10^6))))
print("sort n=7")
print(system.time(sort(rnorm(10^7))))
print(system.time(sort(rnorm(10^7))))
print(system.time(sort(rnorm(10^7))))
# loess
loess.me<-function(n) {
print(paste("loess n=",as.character(n),sep=""))
for (i in 1:5) {
x<-rnorm(10^n); y<-rnorm(10^n); z<-rnorm(10^n)
print(system.time(loess(z~x+y)))
}
}
loess.me(3)
loess.me(4)
# END benchmark tests
cat("END\n\n#####\n\nSTART stochvol speedtest\n\n")
devtools::load_all(".")
set.seed(19891109)
dat <- list(
normsmall = rnorm(20),
normbig = rnorm(2000),
svlsmall = svsim(len = 20, mu = -9, phi = 0.95, sigma = 0.1, rho = 0, nu = Inf)$y,
svlbig = svsim(len = 2000, mu = -9, phi = 0.95, sigma = 0.1, rho = -0.3, nu = Inf)$y
)
for (dataset in names(dat)) {
tmp <- replicate(2, svsample(dat[[dataset]], draws = 10000, burnin = 1000), simplify = FALSE)
tmp <- replicate(2, svtsample(dat[[dataset]], draws = 10000, burnin = 1000), simplify = FALSE)
tmp <- replicate(2, svlsample(dat[[dataset]], draws = 10000, burnin = 1000,
priormu = c(-9, 1), # stability
priorphi = c(10, 10), priorsigma = 0.01, priorrho = c(10, 10),
expert = list(#parameterization = c("centered", "noncentered"),
correct_model_misspecification = TRUE)),
simplify = FALSE)
}
cat("END stochvol speedtest\n\n")
sink(type = "message")
sink()
# some code for testing (AWOL produced NaNs for Darjus, numerically unstable)
if (FALSE) {
dataset <- "normsmall"
set.seed(3)
tmp <- svlsample(dat[[dataset]], draws = 182, burnin = 1000,
#priormu = c(-9, 1),
expert = list(#parameterization = c("centered", "noncentered"),
correct_model_misspecification = FALSE))
plot(tmp)
plot(tmp$adaptation_centered[, 1], type = "l")
plot(tmp$adaptation_centered[, 2], type = "l")
plot(tmp$adaptation_centered[, 3], type = "l")
plot(tmp$adaptation_noncentered[, 1], type = "l")
plot(tmp$adaptation_noncentered[, 2], type = "l")
plot(tmp$adaptation_noncentered[, 3], type = "l")
}