-
Notifications
You must be signed in to change notification settings - Fork 49
/
test-timing.R
30 lines (26 loc) · 1.17 KB
/
test-timing.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
context("timing")
test_that("estimateRegularity", {
# generate Erlang-3 with various lambdas
set.seed(1)
nr_of_customers <- 1000
k <- 3
elog <- rbindlist(lapply(1:nr_of_customers, function(i) {
lambda <- exp(rnorm(1))
data.table(cust = i, t = cumsum(rgamma(50, k, k * lambda)))
}))
# Estimate regularity parameter k
k_est_1 <- estimateRegularity(elog)
k_est_1 <- estimateRegularity(elog, plot = TRUE, min = 2)
expect_error(k_est_1 <- estimateRegularity(elog, plot = TRUE, min = 60), "sufficient")
k_est_1 <- estimateRegularity(elog, plot = TRUE, title = "Plot Title")
k_est_1 <- estimateRegularity(elog, plot = TRUE, title = "")
k_est_2 <- estimateRegularity(elog, method = "mle", plot = TRUE)
k_est_3 <- estimateRegularity(elog, method = "mle-minka", plot = TRUE, title = "Plot Title")
k_est_4 <- estimateRegularity(elog, method = "mle-thom", plot = TRUE, title = "")
k_est_5 <- estimateRegularity(elog, method = "cv", plot = TRUE)
expect_equal(k, k_est_1, tolerance = 0.1)
expect_equal(k, k_est_2, tolerance = 0.1)
expect_equal(k, k_est_3, tolerance = 0.1)
expect_equal(k, k_est_4, tolerance = 0.1)
expect_equal(k, k_est_5, tolerance = 0.1)
})