tnagler / VineCopula

Statistical inference of vine copulas
87 stars 33 forks source link

Vectorized RVineSim #69

Closed notEvil closed 4 years ago

notEvil commented 4 years ago

See https://github.com/tnagler/VineCopula/issues/68

Its intentionally not ready for merge!

r_vine_matrix = VineCopula::RVineMatrix(matrix(c(2, 0, 0, 2, 3, 0, 2, 3, 1), nrow=3), family=matrix(c(0, 0, 0, 1, 0, 0, 1, 1, 0), nrow=3), par=matrix(c(0, 0, 0, 0.3, 0, 0, 0.2, 0.1, 0), nrow=3))
r_vine_matrix
VineCopula::RVineMatrixNormalize(r_vine_matrix)

n = 1e4
seed = as.numeric(Sys.time())

set.seed(seed)
a = VineCopula::RVineSim(n, r_vine_matrix)

set.seed(seed)
b = VineCopula::RVineSim2(n, r_vine_matrix)

all.equal(a, b)
tnagler commented 4 years ago

see #70.

I cleaned the code and only call the vectorized version when necessary. Your R-version had a 1.5x-2x overhead in the "usual" case, which I would like to avoid. Maybe you can check briefly if everything works as expected.