From f35baa0ed19b19be032107f812cc94a2b7582f4c Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 18 Nov 2019 10:22:34 -0600 Subject: fix bug due to roundoff error in get_{delta_ray,shower}_weights() --- src/likelihood.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/likelihood.c') diff --git a/src/likelihood.c b/src/likelihood.c index 5ca9c8d..4a368c6 100644 --- a/src/likelihood.c +++ b/src/likelihood.c @@ -355,7 +355,11 @@ int get_delta_ray_weights(particle *p, double range, double distance_to_psup, do * compute cos(theta) for each of these values, map that value back to x, * and then compute the weight associated with that point. */ for (i = 0; i < n + 1; i++) { - cdf = cdf1 + i*delta; + if (i < n) + cdf = cdf1 + i*delta; + else + cdf = cdf2; + cos_theta = gsl_spline_eval(p->spline_delta,cdf,p->acc_delta); xcdf = cos_theta_to_x(cos_theta,R,cos_gamma,sin_gamma); @@ -446,7 +450,11 @@ int get_shower_weights(particle *p, double distance_to_psup, double *x, double * * compute cos(theta) for each of these values, map that value back to x, * and then compute the weight associated with that point. */ for (i = 0; i < n + 1; i++) { - cdf = cdf1 + i*delta; + if (i < n) + cdf = cdf1 + i*delta; + else + cdf = cdf2; + cos_theta = gsl_spline_eval(p->spline_shower,cdf,p->acc_shower); xcdf = cos_theta_to_x(cos_theta,R,cos_gamma,sin_gamma); -- cgit