https://github.com/richfitz/simplemcmc
https://github.com/richfitz/simplemcmc
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/richfitz/simplemcmc
- Owner: richfitz
- License: other
- Created: 2016-02-23T11:38:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-23T13:31:20.000Z (over 10 years ago)
- Last Synced: 2025-01-20T22:53:54.775Z (over 1 year ago)
- Language: C++
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simplemcmc
> Simple MCMC With Templates
**This is not meant to be used for anything. This is just to illustrate how one might use C++ templates to avoid hassles with using function pointers.**
This is an example of using templates to make a function that needs functions (e.g. an MCMC sampler, optimiser, etc) work easily enough in R + Rcpp. See the demo package at [tests/testthat/demo](tests/testthat/demo) for use in a package (the important bit is the `LinkingTo` field in the [DESCRIPTION](tests/testthat/demo/DESCRIPTION). The package also has the same example in `src` and `R` (which would be the model if you had a sampler that you wanted to use multiple times within a single package).
## Installation
```r
devtools::install_github("richfitz/simplemcmc")
```
## Usage
```
n <- 5
x0 <- rnorm(n)
w <- runif(n, 0, 10)
pars <- c(rnorm(n), runif(n))
samples <- simplemcmc::mcmc_example(x0, w, 1000, pars)
matplot(samples$x, type="l", lty=1)
```
## License
MIT + file LICENSE © [Rich FitzJohn](https://github.com/richfitz).