Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-graham committed Jan 6, 2025
1 parent 75d61f8 commit da2ec80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions R/barker.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ bimodal_barker_proposal <- function(
sample_uniform = stats::runif) {
sample_bimodal <- function(dimension) {
return(
sample(c(-1, 1), dimension, TRUE) * sqrt(1 - sigma^2)
+ stats::rnorm(dimension) * sigma
sample(c(-1, 1), dimension, TRUE) * sqrt(1 - sigma^2) +
stats::rnorm(dimension) * sigma
)
}
barker_proposal(
Expand Down
8 changes: 3 additions & 5 deletions vignettes/adjusting-noise-distribution.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ with two equally-weighted normal components with means $\pm (1 - \sigma^2)$ and
sample_bimodal <- function(dimension) {
sigma <- 0.1
return(
sample(c(-1, 1), dimension, TRUE) * sqrt(1 - sigma^2)
+ stats::rnorm(dimension) * sigma
sample(c(-1, 1), dimension, TRUE) * sqrt(1 - sigma^2) +
stats::rnorm(dimension) * sigma
)
}
```
Expand All @@ -84,11 +84,9 @@ and the second using the bimodal distribution.
```{r}
normal_noise_proposal <- barker_proposal()
bimodal_noise_proposal <- barker_proposal(sample_auxiliary = sample_bimodal)
# Above line is equivalent to
# bimodal_noise_proposal <- bimodal_barker_proposal()
```

A convenience function `bimodal_barker_proposal()` is also provided in the package to simplify creating a proposal with bimodal noise distribution as above, with optional `sigma` argument specifying the standard deviation of the normal components.
A convenience function `bimodal_barker_proposal()` is also provided in the package to simplify creating a proposal with bimodal noise distribution as above, with optional `sigma` argument specifying the standard deviation of the normal components. That is the second line above can equivalently be written `bimodal_noise_proposal <- bimodal_barker_proposal()` without the need to define the `sample_bimodal` function.

## Sampling chains with proposals

Expand Down

0 comments on commit da2ec80

Please sign in to comment.