calamari.fitting.models.segmented_linear#

calamari.fitting.models.segmented_linear(x, x_break, y_break, slope_below, slope_change)#

Two straight lines joined at a sharp corner (a continuous “broken stick”).

y = y_break + slope_below * (x - x_break) + slope_change * max(0, x - x_break), so the slope is slope_below for x < x_break and slope_below + slope_change above it. This is the shape of a kink: a susceptibility whose temperature slope changes at an ordering transition without a peak, or a magnetisation whose field slope changes at a spin-flop.

It is parametrised at the break rather than as a + b x + c max(0, x - x_break). An intercept at x = 0 is an extrapolation far outside the data whenever they sit away from the origin, and it is then almost perfectly anticorrelated with the slope (a transition at 150 K: the correlation rounds to -1 at four decimals). Measured at the corner instead, every correlation is set by the data’s shape alone and is the same wherever the origin of x lies.

The corner is sharp by construction. A real transition is rounded, and a sharp-corner fit to a rounded one places x_break by an amount that depends on where the fitting range sits; see fit_breakpoint() for what that does to the error bar and the check that exposes it.

Parameters:
  • x (ArrayLike) – Independent variable.

  • x_break (float) – Location of the corner, in the units of x.

  • y_break (float) – Model value at the corner.

  • slope_below (float) – Slope for x < x_break.

  • slope_change (float) – Change of slope across the corner: the slope above is slope_below + slope_change.

Return type:

NDArray[double]

Returns:

numpy.ndarray – y at each x.