From 11fe47bef1801331d42457d19a51a9f2c3edb02c Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 11 Feb 2025 17:31:00 +0000 Subject: [PATCH] add sigmoid function to basic models (#307) fixes #306 Co-authored-by: Dominik Demuth Reviewed-on: https://gitea.pkm.physik.tu-darmstadt.de/IPKM/nmreval/pulls/307 --- src/nmreval/models/basic.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/nmreval/models/basic.py b/src/nmreval/models/basic.py index ce4308d..9035d32 100644 --- a/src/nmreval/models/basic.py +++ b/src/nmreval/models/basic.py @@ -203,6 +203,31 @@ class Sinc: return c * np.sinc(((x-x0)/w)/np.pi) +class Sigmoid: + type = 'Basic' + name = 'Sigmoid' + equation = 'C / [1 + exp(-a * (x - x_{0})] + y_{0}' + params = ['C', 'a', 'x_{0}', 'y_{0}'] + + @staticmethod + def func(x, c, a, x0, y0): + """ + Sigmoid function + + .. math:: + y = C / [1 + exp(-a * (x - x_0))] + y_0 + + Args: + x (array_like): Input values + c (float): Prefactor + a (float): Steepness of the sigmoid + x0 (float): x position of the sigmoid's midpoint + y0 (float): y position of the sigmoid's midpoint + + """ + return c / (1 + np.exp(-a * (x - x0))) + y0 + + class Sine: """ Wavy sine function