Closed hsloot closed 4 years ago
inst/Rprofile/prof_v2_0_0.R:1:2: style: Commented code should be removed.
#+ setup
^~~~~~~
library("rmo")
library("magrittr")
library("ggplot2")
library("microbenchmark")
use_seed <- 1632L
n <- 1e2L
d <- 7L
We use a compound Poisson process with intensity 0
and fixed
deterministic jumps of size eta
. Additionally, we allow killing
and a drift. This model is convenient, as it can be used to parametrise
all used models from this package.
rate <- 0
eta <- 1 # dummy
rate_killing <- 0.1 / 0.4
rate_drift <- 0.3 / 0.4
psi <- function(x) {
ifelse(x > 0, rate_killing, 0) + rate_drift * x +
rate * (1 - exp(-eta * x))
}
ex_intensities <- numeric(d)
ex_intensities[1] <- rate_drift
ex_intensities[d] <- rate_killing
intensities <- numeric(2^d-1)
for (j in 1:(2^d-1)) {
tmp <- 0
for (i in 1:d) {
tmp <- tmp + rmo:::is_within(i, j)
}
intensities[j] <- ex_intensities[[tmp]]
}
alpha <- rate_drift
beta <- rate_killing
set.seed(use_seed)
mb1 <- microbenchmark(
ESM = rmo_esm(n, d, intensities),
Arnold = rmo_arnold(n, d, intensities),
Ex_Arnold = rmo_ex_arnold(n, d, ex_intensities),
LFM_CPP = rmo_lfm_cpp(n, d, rate, rate_killing, rate_drift,
rjump_name = "rposval", rjump_arg_list = list("value"=1)),
Cuadras_Auge = rmo_esm_cuadras_auge(n, d, alpha, beta)
)
detach("package:rmo", unload = TRUE)
tmpdir <- tempdir()
suppressMessages(devtools::install_github("hsloot/rmo@v0.1.2", lib = tmpdir, quiet = TRUE))
library(rmo, lib.loc = tmpdir)
set.seed(1632L)
mb2 <- microbenchmark(
ESM = rmo_esm(n, d, intensities),
Arnold = rmo_arnold(n, d, intensities),
Ex_Arnold = rmo_ex_arnold(n, d, ex_intensities),
LFM_CPP = rmo_lfm_cpp(n, d, rate, rate_killing, rate_drift,
rjump_name = "rposval", rjump_arg_list = list("value"=1)),
Cuadras_Auge = rmo_esm_cuadras_auge(n, d, alpha, beta)
)
detach("package:rmo", unload = TRUE)
# invisible(print(unlink(tmpdir, recursive = TRUE)))
mb1 %>%
autoplot()
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
mb2 %>%
autoplot()
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
Created on 2020-02-10 by the reprex package (v0.3.0)
Description
Refactor all sampling algorithms in with
Rcpp
to improve speed.Checklist
R CMD CHECK
successfulOnly for new or refactored algorithms:
Optional, but recommended:
lintr::lint_package()
without errors