Last active
July 2, 2021 11:39
-
-
Save JohannesNE/c443cff9c5f6230884f3b3a1904d2894 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rethinking) | |
library(cmdstanr) | |
library(microbenchmark) | |
X <- data.frame(x = rnorm(100, 9, 2)) | |
fit_mean <- function(cmdstan) { | |
ulam( | |
alist( | |
x ~ normal( mu , Sigma ), | |
mu ~ normal(0, 5), | |
Sigma ~ exponential( 1 ) | |
), data=X , chains=4 , cores=4 , cmdstan=cmdstan ) | |
} | |
microbenchmark("cmdstan" = fit_mean(cmdstan = TRUE), | |
"rstan" = fit_mean(cmdstan = FALSE), | |
times = 10) | |
# Unit: seconds | |
# expr min lq mean median uq max neval | |
# cmdstan 14.811175 14.981982 15.402317 15.177852 15.90549 16.54465 10 | |
# rstan 3.722226 3.805964 9.465478 3.900478 21.54825 22.83466 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment