A convenience function used to arrange vectorised matrix samples into the correct
matrix format for several functions used to specify Markov model. See example_two_state_markov
for an example use case. Implemented using Rcpp.
MatrixArrange(samples)
samples | A list of vectorised matrix samples |
---|
A list of matrices with each matrix representing a single sample.
matrix_samples <- list(VGAM::rdiric(1:5, c(88, 12)), VGAM::rdiric(1:5, c(8, 92))) # R implementation samples_r <- matrix_arrange_inner(matrix_samples) # Rcpp implementation samples_rcpp <- MatrixArrange(matrix_samples) all.equal(samples_r, samples_rcpp)#> [1] TRUE# Benchmark library(microbenchmark) microbenchmark(matrix_arrange_inner(matrix_samples), MatrixArrange(matrix_samples), times = 1000)#> Unit: microseconds #> expr min lq mean median uq #> matrix_arrange_inner(matrix_samples) 50.598 56.7455 61.202177 59.0810 61.6050 #> MatrixArrange(matrix_samples) 3.815 4.5620 5.631948 5.3415 6.0735 #> max neval #> 291.888 1000 #> 32.343 1000