specparam.modes.funcs.triangle_function

specparam.modes.funcs.triangle_function(xs, *params)[source]

Triangle fitting function.

Parameters:
xs1d array

Input x-axis values.

*paramsfloat

Parameters that define a triangle function. Each triangle peak has 3 parameters: ctr, hgt, wid.

Returns:
ys1d array

Output values for triangle function.

Notes

Defines a triangular fit function as:

\[\begin{split}\text{tri}(x) = \begin{cases} 1 - |x| & \text{if } |x| < 1 \\ 0 & \text{if } |x| \geq 1 \end{cases}\end{split}\]

To use this function as a peak function, this function is scaled by hgt and wid, and moved to ctr.