A Base R, simple implementation of the No-Underrun Sampler. This package aims to mostly directly implement the algorithm as described by th
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

R 77.7%
Other 22.3%
9 1 0

Clone this repository

https://tangled.org/visruth.com/R.NURS https://tangled.org/did:plc:xfguhlqnw7pbioeiismqdmhb/R.NURS
git@tangled.org:visruth.com/R.NURS git@tangled.org:did:plc:xfguhlqnw7pbioeiismqdmhb/R.NURS

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

R.NURS#

A Base R, simple implementation of the No-Underrun Sampler. This package aims to mostly directly implement the algorithm as described by the paper, with at most small changes for code aesthetics and performance. This version uses the memory saving technique described in section 2.2.

This code doesn’t parallelize the density calculation for orbit extensions but doing so is trivial.

Installation#

You can install the development version of R.NURS from GitHub with:

# install.packages("pak")
pak::pak("VisruthSK/R.NURS")

Example: Neal’s Funnel#

library(R.NURS)
library(ggplot2)

set.seed(0)
logpdf_funnel <- function(theta) {
  y <- theta[1]
  dnorm(y, 0, 3, log = TRUE) + sum(dnorm(theta[-1], 0, exp(y / 2), log = TRUE))
}

samples <- NURS(
  logpdf_funnel,
  theta_init = rep(0, 15),
  n = 5000,
  epsilon = 0.1,
  h = 0.5,
  M = 5
)

data.frame(y = samples[, 1], x1 = samples[, 2]) |>
  ggplot(aes(x = y, y = x1)) +
  geom_point(alpha = 0.3) +
  theme_minimal()

References#