Skip to content

WetRobot/itertracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

itertracer

Build Status AppVeyor Build Status

itertracer enables easy tracing of an iterative process such as Gibbs sampling.

Installation

devtools::install_github("WetRobot/itertracer")

Example

This is a basic example which shows you how to solve a common problem:

library(itertracer)

## beta-binomial Gibbs sampling, multi-core

g <- itertracer(
  fixed = list(n = 20L),
  param_init = lapply(list(x = 10, theta = 0.5), as.array),
  step_funs = list(
    x = function(arg_list) {
      rbinom(
        n = 1,
        size = arg_list[["fixed"]][["n"]],
        prob = arg_list[["param_list"]][["theta"]]
      )
    },
    theta = function(arg_list) {
      rbeta(
        n = 1,
        shape1 = 2 + arg_list[["param_list"]][["x"]],
        shape2 = 4 + arg_list[["fixed"]][["n"]] - arg_list[["param_list"]][["x"]]
      )
    }
  ),
  n_chains = 1L,
  n_iter = 300,
  n_burn = 50L,
  n_skip = 4L,
  n_parallel = 1L
)

About

Trace an iterative process

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages