joint_d: Joint Density Calculator

Description Usage Arguments Value Examples

View source: R/samplers.R

Description

Helper function for Hamiltonian Samplers that calculates the log joint density of a position and momentum pair.

Usage

1
joint_d(theta, momentum, logf)

Arguments

theta

Vector. Position

momentum

Vector, momentum.

logf

function. Log probability density function of the target distribution

Value

Numeric. Log joint density of the theta/momentum pair

Examples

1
2
3
4
5
6
7
# This function is internally used

target <- distr6::Normal$new()
log_func <- function (x){return(target$pdf(log=TRUE, data = matrix(x, nrow=1)))}
theta <- target$mean()
momentum <- as.vector(mvtnorm::rmvnorm(1, 0))
joint_d(theta, momentum, log_func)

lucas-castillo/SampleR documentation built on Jan. 1, 2021, 8:25 a.m.