Skip to content

Commit

Permalink
Fix pre-commit errors in existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-graham committed Aug 2, 2024
1 parent 54a6dd9 commit 8d033b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
14 changes: 6 additions & 8 deletions R/barker.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ log_density_ratio_barker <- function(
scale_and_shape) {
sum(
log1p_exp(
state$momentum()
* (
Matrix::drop(Matrix::t(scale_and_shape))
* state$gradient_log_density(target_distribution)
state$momentum() * Matrix::drop(
Matrix::t(scale_and_shape) *
state$gradient_log_density(target_distribution)
)
) - log1p_exp(
proposed_state$momentum()
* (
Matrix::drop(Matrix::t(scale_and_shape))
* proposed_state$gradient_log_density(target_distribution)
proposed_state$momentum() * Matrix::drop(
Matrix::t(scale_and_shape) *
proposed_state$gradient_log_density(target_distribution)
)
)
)
Expand Down
6 changes: 3 additions & 3 deletions R/kernels.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ sample_metropolis_hastings <- function(
sample_uniform = stats::runif) {
proposed_state <- proposal$sample(state)
log_accept_ratio <- (
proposed_state$log_density(target_distribution)
- state$log_density(target_distribution)
+ proposal$log_density_ratio(state, proposed_state)
proposed_state$log_density(target_distribution) -
state$log_density(target_distribution) +
proposal$log_density_ratio(state, proposed_state)
)
accept_prob <- if (is.nan(log_accept_ratio)) 0 else min_1_exp(log_accept_ratio)
if (sample_uniform(1) < accept_prob) {
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
url: http://github-pages.ucl.ac.uk/rmcmc/
template:
bootstrap: 5

3 changes: 2 additions & 1 deletion tests/testthat/test-langevin.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ for (dimension in c(1L, 2L, 3L)) {
sprintf(
"Langevin involution is an involution (dimension %i, scale %.1f)",
dimension, scale
), {
),
{
target_distribution <- standard_normal_target_distribution()
withr::with_seed(seed = default_seed(), {
state <- chain_state(
Expand Down

0 comments on commit 8d033b3

Please sign in to comment.