Skip to content

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

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

VisruthSK/R.NURS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Languages