knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(SampleR)
Make pd_func
target <- distr::Norm(0,3) pd_func <- make_distr_pdf(target)
Epsilon too small
epsilon <- .01 set.seed(1) hmc_results <- sampler_hmc(pd_func, epsilon = epsilon, L = 10, start = 0) hist(hmc_results[[1]], probability = TRUE) curve(dnorm(x, mean=0, sd=3), add=TRUE)
Right size
epsilon <- 1 set.seed(1) hmc_results <- sampler_hmc(pd_func, epsilon = epsilon, L = 10, start = 0) hist(hmc_results[[1]], probability = TRUE) curve(dnorm(x, mean=0, sd=3), add=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.