Skip to content

Commit

Permalink
replot sinusoid figures with larger fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
odunbar committed Apr 22, 2024
1 parent 18d88b8 commit c154dc3
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 15 deletions.
3 changes: 3 additions & 0 deletions examples/Sinusoid/calibrate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ p = plot(
legend = :bottomright,
xlims = (0, 6),
ylims = (-6, 10),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
vline!([theta_true[1]], color = :red, style = :dash, label = :false)
hline!([theta_true[2]], color = :red, style = :dash, label = :false)
Expand Down
78 changes: 70 additions & 8 deletions examples/Sinusoid/emulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# First, we load the packages we need:
using LinearAlgebra, Random

using Distributions, Plots
using Distributions, Plots, Plots.PlotMeasures
using JLD2

using CalibrateEmulateSample
Expand Down Expand Up @@ -179,7 +179,15 @@ p2 = contour(
ylabel = "Vertical Shift",
title = "True Sinusoid Mean",
)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
size = (600, 300),
layout = (1, 2),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_groundtruth_contours.png"))
# The first panel shows how the range varies with respect to the two parameters in the Gaussian process
# emulator. The contours show the range is mostly dependent on the amplitude, with little variation with
Expand Down Expand Up @@ -212,7 +220,17 @@ p2 = contour(
title = "GP Sinusoid Mean",
)
plot!(inputs[1, :], inputs[2, :]; seriestype = :scatter, zcolor = outputs[2, :], label = :false)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
right_margin=3mm,
bottom_margin=3mm,
size = (600, 300),
layout = (1, 2),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_GP_emulator_contours.png"))

# Plot RF emulator contours
Expand All @@ -238,7 +256,17 @@ p2 = contour(
title = "RF Sinusoid Mean",
)
plot!(inputs[1, :], inputs[2, :]; seriestype = :scatter, zcolor = outputs[2, :], label = :false)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
right_margin=3mm,
bottom_margin=3mm,
size = (600, 300),
layout = (1, 2),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_RF_emulator_contours.png"))

# Both the GP and RF emulator give similar results to the ground truth G(θ), indicating they are correctly
Expand Down Expand Up @@ -272,7 +300,17 @@ p2 = contour(
ylabel = "Vertical Shift",
title = "GP 1σ in Sinusoid Mean",
)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
size = (600, 300),
layout = (1, 2),
right_margin=3mm,
bottom_margin=3mm,
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_GP_emulator_std_contours.png"))


Expand All @@ -299,7 +337,15 @@ p2 = contour(
ylabel = "Vertical Shift",
title = "RF 1σ in Sinusoid Mean",
)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
size = (600, 300),
layout = (1, 2),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_RF_emulator_std_contours.png"))
# The GP and RF uncertainty predictions are similar and show lower uncertainties around the region of interest
# where we have more training points.
Expand Down Expand Up @@ -331,7 +377,15 @@ p2 = contour(
ylabel = "Vertical Shift",
title = "GP error in Sinusoid Mean",
)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
size = (600, 300),
layout = (1, 2),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_GP_errors_contours.png"))

rf_diff_grid = abs.(rf_grid - g_true_grid)
Expand All @@ -357,7 +411,15 @@ p2 = contour(
ylabel = "Vertical Shift",
title = "RF error in Sinusoid Mean",
)
p = plot(p1, p2, size = (600, 300), layout = (1, 2))
p = plot(
p1,
p2,
size = (600, 300),
layout = (1, 2),
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)
savefig(p, joinpath(data_save_directory, "sinusoid_RF_errors_contours.png"))

# Here, we want the emulator to show the low errors in the region around the true parameter values near θ = (3, 6),
Expand Down
12 changes: 6 additions & 6 deletions examples/Sinusoid/sample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ plot_all = plot(
layout = layout,
size = (600, 600),
legend = :true,
guidefontsize = 8,
tickfontsize = 6,
legendfontsize = 6,
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)

savefig(plot_all, joinpath(data_save_directory, "sinusoid_MCMC_hist_GP.png"))
Expand Down Expand Up @@ -293,9 +293,9 @@ plot_all = plot(
layout = layout,
size = (600, 600),
legend = :true,
guidefontsize = 8,
tickfontsize = 6,
legendfontsize = 6,
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)

savefig(plot_all, joinpath(data_save_directory, "sinusoid_MCMC_hist_RF.png"))
Expand Down
10 changes: 9 additions & 1 deletion examples/Sinusoid/sinusoid_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ function generate_obs(amplitude_true, vert_shift_true, Γ; rng = Random.GLOBAL_R
# Generate the "true" signal for these parameters
signal_true = model(amplitude_true, vert_shift_true; rng = rng)
# Plot
p = plot(signal_true, color = :black, linewidth = 3, label = "True signal")
p = plot(
signal_true,
color = :black,
linewidth = 3,
label = "True signal",
guidefontsize = 14,
tickfontsize = 12,
legendfontsize = 12,
)

# We will observe properties of the signal that inform us about the amplitude and vertical
# position. These properties will be the range (the difference between the maximum and the minimum),
Expand Down
Binary file modified sinusoid_GP_emulator_contours.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sinusoid_MCMC_hist_GP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sinusoid_eki_pairs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sinusoid_true_vs_observed_signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c154dc3

Please sign in to comment.