diff --git a/Utils.jl b/Utils.jl index 80748f1..2756c42 100644 --- a/Utils.jl +++ b/Utils.jl @@ -77,6 +77,10 @@ function lowpass_filter(i; σ=1) return r end +function residuals(I_data, I_model, err) + return (I_data .- I_model ./ err) .^ 2 +end + function chi2(I_data, I_model, err) return sum((I_data .- I_model ./ err) .^ 2) end diff --git a/test.jl b/test.jl index 2f602fb..b3e4885 100644 --- a/test.jl +++ b/test.jl @@ -68,14 +68,21 @@ padding_factor[18] = 10.0 bounds = MH.boxconstraints(lb=lb_reduced, ub=ub_reduced) -function obj(P) +function obj_χ2(P) I_model, neg_H20 = intensity_reduced(P) χ2 = Utils.chi2(I_data, I_model, err) factor = (neg_H20 == 0 ? 1.0 : 5.0 * (neg_H20 + 1)) return factor * χ2 end -barriered_obj = Utils.add_log_barriers(obj, simple_bounds; padding_factor=padding_factor) +function obj_residuals(P) + I_model, neg_H20 = intensity_reduced(P) + residuals = Utils.residuals(I_data, I_model, err) + factor = (neg_H20 == 0 ? 1.0 : 5.0 * (neg_H20 + 1)) + return factor * residuals +end + +barriered_obj = Utils.add_log_barriers(obj_residuals, simple_bounds; padding_factor=padding_factor) information = MH.Information(f_optimum=0.0) information = MH.Information()