This folder contains:
my_functions.R: core functions used by all scripts (do not edit unless you intend to change the methods).Figure_*.R: scripts that generate the paper figures intoFigures/.mc_interpolate_BB_*.R: Monte Carlo scripts that benchmark the rejection samplers used byinterpolate_BB_*.
- R (recent version recommended)
- Packages used across scripts:
ggplot2,latex2exppatchwork(used byFigure_005.R,Figure_006.R,Figure_007.R,Figure_008.R)gridExtra(used byFigure_002.R)
Install packages in R if needed:
install.packages(c("ggplot2", "latex2exp", "patchwork", "gridExtra"))Run from this directory (so relative paths like Figures/... resolve):
Rscript Figure_001.RTo (re)generate all figures:
for f in Figure_*.R; do Rscript "$f"; doneOutputs
- Most scripts write
.pngfiles toFigures/viaggsave(). - Some scripts also save plot objects as
.rdsinFigures/(e.g.,Figures/p_005a.rds).
These scripts report, for each scenario:
- Acceptance rate of the rejection sampler inside
interpolate_BB_*, estimated as:acceptance_rate = B_accept / total_proposals- where
total_proposalsis counted by temporarily wrapping the proposal generator (extrapolate_bm_Iorextrapolate_bm_II).
- Elapsed wall-clock time to generate
B_time = 10000accepted draws, usingsystem.time(...)[["elapsed"]].
Run individually:
Rscript mc_interpolate_BB_I.R
Rscript mc_interpolate_BB_II.R
Rscript mc_interpolate_BB_III.R
Rscript mc_interpolate_BB_IV.RWhat varies in each script
mc_interpolate_BB_I.R: fixesa=2,T=3, usest ∈ {0.2, 1.5, 2.8}, variesxandzover grids in(0,a).mc_interpolate_BB_II.R: fixesa=2,T=3, usest ∈ {0.2, 1.5, 2.8}, varieszover a grid in(0,a).mc_interpolate_BB_III.R: fixesa=2,T=3, usest ∈ {0.2, 1.5, 2.8}, variesxover a grid in(0,a).mc_interpolate_BB_IV.R: fixesa=2,T=3, usest ∈ {0.2, 1.5, 2.8}(no endpoint grid in this case).
Outputs
Each script writes two CSV files with a timestamped run_id:
mc_interpolate_BB_*.csv: per-scenario results (includes acceptance rate and elapsed seconds for 10,000 draws).mc_interpolate_BB_*_summary_by_t_<run_id>.csv: a simple summary byt.- For
mc_interpolate_BB_I.R, the summary is averaged over the(x,z)grid:- mean acceptance rate over
(x,z) - median elapsed time (over
(x,z)) to generate 10,000 draws
- mean acceptance rate over
- For
In each mc_interpolate_BB_*.R file you can edit:
- grid sizes (
x_grid_n,z_grid_n) and the boundary buffereps B_accept(acceptance-rate accuracy)B_time(timed number of accepted draws; currently 10,000)timing_reps(set>1to repeat timings and take the median across repeats)