gundam-organization / gundam

GUNDAM, for Generalized and Unified Neutrino Data Analysis Methods, is a suite of applications which aims at performing various statistical analysis with different purposes and setups.
GNU Lesser General Public License v2.1
13 stars 10 forks source link

Resolve LTS/1.8.x issue 494: Check spline monotonicity #496

Closed ClarkMcGrew closed 4 months ago

ClarkMcGrew commented 4 months ago

Adds validation for making the spline knot slopes meet the Fritsche-Carlson monotonicity requirements. This also separates the actual Fritsche-Carlson code out of the specific DialFactory so that it can be used outside of that class. It is no longer a class method.

ClarkMcGrew commented 4 months ago

For Ciro: I thought about it some more, and implemented our second criterion for the slopes at the end points. I think it is the least surprising behavior. The options were

  1. Don't change the slope at the end point
  2. At the end point, the an extra fake point is calculated assuming linear extrapolation with the end point slope.
  3. End point slope is zero

Option 1 results on non-monotonic splines, so it's not a good idea. Option 3 severely distorts otherwise monotonic splines. That leaves option 2. It gives a visually reasonable behavior, and the interpolated spline is always monotonic. It also makes sure that splines that already meet the monotonic criteria are left alone. See attached figure. The red is the a parent TSpline3, and the black is the monotonic correction. 100CheckMakeMonotonicSpline1