What parameters can be used with the hyperbolic tangent function to enable optimised curve fitting

curveshyperbolic-functionsregression

If I want to fit a sigmoid curve to data using the logistic function I use something like

$$y = \frac{L}{1 + \exp[-k(x-x_{0})]} + b$$

where $L$, $k$, $x_{0}$ and $b$ are functional parameters that can be varied to achieve the optimal curve fit. In particular, $L$ and $b$ here represent the upper and lower limits respectively of the range of possible values for $y$ (and so may be fixed parameters rather than variable). The other parameters, $k$ and $x_{0}$ affect the gradient of the curve and its mid-point relative to the $x$-axis respectively. These could be varied to optimise a fit of the curve to data points.

Where should I insert parameters into the hyperbolic function to enable similarly arbitrary curve fitting in the same way, if I would like similar behaviour (ie definition of $y_{\rm{min}}$ and $y_{\rm{max}}$, slope and mid-point, or similarly useful parameters)?

$$y = \tanh(x) = \frac{e^{x} – e^{-x}}{e^{x} + e^{-x}}$$

Best Answer

They are the same family, since $$ \tanh(x)=\frac{e^x-e^{-x}}{e^x+e^{-x}}=\frac{-2}{1+\exp(2x)}+1=\frac{2}{1+\exp(-2x)}-1. $$

So, whereas $y=\dfrac{L}{1 + \exp(-k(x-x_0))} + b$ has range between $b$ and $b+L$ exclusive, $x_0$ is the central value and $k$ is a slope control, $$ y=A\tanh(k(x-x_0))+B $$ has range between $B\pm A$ exclusive, same $x_0$ but here $k$ differs by a factor of $2$.

Related Question