
Load Stored Proposal
load_proposal.Rd
This function loads a proposal into memory that was previously saved using the save_proposal()
function. It is useful for retrieving saved proposals for further analysis or processing.
Value
Returns a list representing the proposal stored under proposal_name
in R's internal data directory. If the proposal corresponding to the specified name does not exist, an error message is displayed.
Examples
# First, let's create a proposal to sample from a standard normal distribution
f_normal <- function(x) { 0.3989423 * exp(-0.5 * x^2) }
normal_proposal = build_proposal(f = f_normal, modes = 0, lower = -Inf, upper = Inf, steps = 1000)
print(normal_proposal)
#>
#> ── Proposal Summary ────────────────────────────────────────────────────────────
#> • Total steps: 1,000
#> • Steps range: [-2.876766, 2.876766]
#> • Sampling efficiency: 99.56%
# Then, save this proposal in R's internal data directory using
# `save_proposal()` with the name "normal"
save_proposal(normal_proposal, "normal")
# Now, in case the R session is restarted and the proposal is no longer in memory,
# it can be loaded from the machine as follows:
loaded_normal_proposal <- load_proposal("normal")
print(loaded_normal_proposal)
#>
#> ── Proposal Summary ────────────────────────────────────────────────────────────
#> • Total steps: 1,000
#> • Steps range: [-2.876766, 2.876766]
#> • Sampling efficiency: 99.56%