nlsq.core.functions.sigmoid¶
- nlsq.core.functions.sigmoid(x, L, x0, k, b)[source]¶
Sigmoid (logistic) function: y = L / (1 + exp(-k*(x-x0))) + b
Common for dose-response curves, growth saturation, S-curves.
- Parameters:
- Returns:
y – Dependent variable
- Return type:
array_like
Notes
At x=x0: y = L/2 + b (midpoint)
As x→-∞: y → b (lower asymptote)
As x→+∞: y → L + b (upper asymptote)
Steeper curve: larger k
Examples
>>> from nlsq import curve_fit >>> from nlsq.core.functions import sigmoid >>> import numpy as np >>> >>> # Dose-response curve >>> x = np.linspace(0, 10, 100) >>> y = 5 / (1 + np.exp(-2*(x-5))) + 1 + np.random.normal(0, 0.1, 100) >>> popt, pcov = curve_fit(sigmoid, x, y, p0='auto') >>> print(f"EC50 (midpoint): {popt[1]:.2f}")