Construct target distribution from a formula specifying log density.
Source:R/bridges.R
target_distribution_from_log_density_formula.Rd
Construct target distribution from a formula specifying log density.
Value
A list with entries
log_density
: A function to evaluate log density function for target distribution given current position vector.value_and_gradient_log_density
: A function to evaluate value and gradient of log density function for target distribution given current position vector, returning as a list with entriesvalue
andgradient
.
Examples
target_distribution <- target_distribution_from_log_density_formula(
~ (-(x^2 + y^2) / 8 - (x^2 - y)^2 - (x - 1)^2 / 10)
)
target_distribution$value_and_gradient_log_density(c(0.1, -0.3))
#> $value
#> [1] -0.1896
#>
#> $gradient
#> x y
#> 0.031 0.695
#>