Skip to content

Slight inconsistency in the correlation function interface (C++) #17

Description

@misharash

When the correlation function is read from the file, its internal mu range is set to 0-1:

// Mu range hardcoded to be between 0 and 1
mumin=0.;
mumax=1.;

However, when the correlation function is reset from arrays during the rescaling procedure (which tries to ensure that the averages of the interpolated correlation function over the bins are closer to the input correlation function), its internal mu range bounds are set as the middles of the first and last bins:
new_cf = new CorrelationFunction(new_xi_array, r_centers, mu_centers, nbin, mbin);
and
mumin=mu_array[0];
mumax=mu_array[mbin-1];

This came up in a sudden convergence issue fixed by a8182e1.
With that, the code should be restored to the old behavior, but it is an inconsistency nevertheless. This affects the behavior of the correlation function in the outer halves of the outermost mu bins: it is (bicubically) extrapolated or just reset to the value at the middle of the mu bin in question:
if(r>rmax){
double tmu = fmin(fmax(mu,mumin),mumax);
// Choose r-max to ensure function integrates to zero
return gsl_interp2d_eval_extrap(interp_2d,y,x,z,tmu,rmax, xa, ya)/pow(rmax,2)*pow(r/rmax,-4.);
}
else if(r<rmin){
double tmu = fmin(fmax(mu,mumin),mumax);
return smooth_transition(r, rmin/2., rmin, gsl_interp2d_eval_extrap(interp_2d, y, x, z, tmu, rmin/2., xa, ya)/pow(rmin/2., 2), gsl_interp2d_eval_extrap(interp_2d, y, x, z, tmu, r, xa, ya)/pow(r, 2)); // this ensures xi goes as constant below rmin/2 (rmin is the middle of smallest bin) and not as 1/r which might cause problems, and the transition is smooth
}
if(mu<mumin){
double tr = fmin(fmax(r,rmin),rmax);
return gsl_interp2d_eval_extrap(interp_2d,y,x,z,mumin,tr, xa, ya)/pow(tr,2);
}
else if(mu>mumax){
double tr = fmin(fmax(r,rmin),rmax);
return gsl_interp2d_eval_extrap(interp_2d,y,x,z,mumax,tr, xa, ya)/pow(tr,2);
}
else{
return gsl_interp2d_eval_extrap(interp_2d,y,x,z,mu,r, xa, ya)/pow(r,2);
}

Either option has its advantages and disadvantages. The current state does not allow loading the rescaled correlation function (saved to a file) to avoid spending time on the rescaling procedure in repeated runs and get (more) consistent results.
Probably easiest to set the internal mu range between the outermost bin centers when reading from file (initial correlation function setup).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions