Logistic function#

Several forms of the logistic function and their first and second derivatives

The current functions are the following. Each function has a second form with _p appended to the name, where parameters are given as an iterable, e.g. logistic and logistic_p = logistic(x, *p):

Function

Description

logistic

Logistic function L/(1+exp(-k(x-x0)))

dlogistic

First derivative of logistic function

d2logistic

Second derivative of logistic function

logistic_offset

logistic function with offset L/(1+exp(-k(x-x0))) + a

dlogistic_offset

First derivative of logistic function with offset

d2logistic_offset

Second derivative of logistic function with offset

logistic2_offset

Double logistic function with offset L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a

dlogistic2_offset

First derivative of double logistic function with offset

d2logistic2_offset

Second derivative of double logistic function with offset

This module was written by Matthias Cuntz while at Department of Computational Hydrosystems, Helmholtz Centre for Environmental Research - UFZ, Leipzig, Germany, and continued while at Institut National de Recherche pour l’Agriculture, l’Alimentation et l’Environnement (INRAE), Nancy, France.

copyright:

Copyright 2015-2022 Matthias Cuntz, see AUTHORS.rst for details.

license:

MIT License, see LICENSE for details.

Functions:

logistic(x, L, k, x0)

Logistic function

logistic_p(x, p)

Wrapper function for logistic(): logistic(x, *p)

dlogistic(x, L, k, x0)

First derivative of logistic() function

dlogistic_p(x, p)

Wrapper function for dlogistic(): dlogistic(x, *p)

d2logistic(x, L, k, x0)

Second derivative of logistic() function

d2logistic_p(x, p)

Wrapper function for d2logistic(): d2logistic(x, *p)

logistic_offset(x, L, k, x0, a)

Logistic function with offset

logistic_offset_p(x, p)

Wrapper function for logistic_offset(): logistic_offset(x, *p)

dlogistic_offset(x, L, k, x0, a)

First derivative of logistic_offset() function

dlogistic_offset_p(x, p)

Wrapper function for dlogistic_offset(): dlogistic_offset(x, *p)

d2logistic_offset(x, L, k, x0, a)

Second derivative of logistic_offset() function

d2logistic_offset_p(x, p)

Wrapper function for d2logistic_offset(): d2logistic_offset(x, *p)

logistic2_offset(x, L1, k1, x01, L2, k2, x02, a)

Double logistic function with offset

logistic2_offset_p(x, p)

Wrapper function for logistic2_offset(): logistic2_offset(x, *p)

dlogistic2_offset(x, L1, k1, x01, L2, k2, x02, a)

First derivative of logistic2_offset() function

dlogistic2_offset_p(x, p)

Wrapper function for dlogistic2_offset(): dlogistic2_offset(x, *p)

d2logistic2_offset(x, L1, k1, x01, L2, k2, ...)

Second derivative of logistic_offset() function

d2logistic2_offset_p(x, p)

Wrapper function for d2logistic2_offset(): d2logistic2_offset(x, *p)

History
  • Written Mar 2015 by Matthias Cuntz (mc (at) macu (dot) de)

  • Added functions logistic_p and logistic_offset_p, Dec 2017, Matthias Cuntz

  • Changed to Sphinx docstring and numpydoc, Dec 2019, Matthias Cuntz

  • Distinguish iterable and array_like parameter types, Jan 2020, Matthias Cuntz

  • Make systematically function_p versions of all logistic functions and its derivatives, Feb 2020, Matthias Cuntz

  • Split logistic and curvature into separate files, May 2020, Matthias Cuntz

  • More consistent docstrings, Jan 2022, Matthias Cuntz

d2logistic(x, L, k, x0)[source]#

Second derivative of logistic() function

\[L/(1+exp(-k(x-x0)))\]

which is

\[-k^2.L.sinh(k(x-x0))/(2(cosh(k(x-x0))+1)^2)\]
Parameters:
  • x (array_like) – Independent variable to evalute derivative of logistic function

  • L (float) – Maximum of logistic function

  • k (float) – Steepness of logistic function

  • x0 (float) – Inflection point of logistic function

Returns:

Second derivative of logistic function at x with maximum L, steepness k and inflection point x0

Return type:

float or ndarray

d2logistic2_offset(x, L1, k1, x01, L2, k2, x02, a)[source]#

Second derivative of logistic_offset() function

\[L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a\]

which is

\[- k1^2.L1.sinh(k1(x-x01)) / (2(cosh(k1(x-x01))+1)^2) + k2^2.L2.sinh(k2(x-x02)) / (2(cosh(k2(x-x02))+1)^2)\]
Parameters:
  • x (array_like) – Independent variable to evalute logistic function

  • L1 (float) – Maximum of first logistic function

  • k1 (float) – Steepness of first logistic function

  • x01 (float) – Inflection point of first logistic function

  • L2 (float) – Maximum of second logistic function

  • k2 (float) – Steepness of second logistic function

  • x02 (float) – Inflection point of second logistic function

  • a (float) – Offset of double logistic function

Returns:

Second derivative of double logistic function with offset at x

Return type:

float or ndarray

d2logistic2_offset_p(x, p)[source]#

Wrapper function for d2logistic2_offset(): d2logistic2_offset(x, *p)

d2logistic_offset(x, L, k, x0, a)[source]#

Second derivative of logistic_offset() function

\[L/(1+exp(-k(x-x0))) + a\]

which is

\[-k^2.L.sinh(k(x-x0))/(2(cosh(k(x-x0))+1)^2)\]
Parameters:
  • x (array_like) – Independent variable to evalute derivative of logistic function

  • L (float) – Maximum of logistic function

  • k (float) – Steepness of logistic function

  • x0 (float) – Inflection point of logistic function

  • a (float) – Offset of logistic function

Returns:

Second derivative of logistic function at x with maximum L, steepness k, inflection point x0, and offset a

Return type:

float or ndarray

d2logistic_offset_p(x, p)[source]#

Wrapper function for d2logistic_offset(): d2logistic_offset(x, *p)

d2logistic_p(x, p)[source]#

Wrapper function for d2logistic(): d2logistic(x, *p)

dlogistic(x, L, k, x0)[source]#

First derivative of logistic() function

\[L/(1+exp(-k(x-x0)))\]

which is

\[k.L/(2(cosh(k(x-x0))+1))\]
Parameters:
  • x (array_like) – Independent variable to evalute derivative of logistic function

  • L (float) – Maximum of logistic function

  • k (float) – Steepness of logistic function

  • x0 (float) – Inflection point of logistic function

Returns:

First derivative of logistic function at x with maximum L, steepness k and inflection point x0

Return type:

float or ndarray

dlogistic2_offset(x, L1, k1, x01, L2, k2, x02, a)[source]#

First derivative of logistic2_offset() function

\[L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a\]

which is

\[k1.L1/(2(cosh(k1(x-x01))+1)) - k2.L2/(2(cosh(k2(x-x02))+1))\]
Parameters:
  • x (array_like) – Independent variable to evalute logistic function

  • L1 (float) – Maximum of first logistic function

  • k1 (float) – Steepness of first logistic function

  • x01 (float) – Inflection point of first logistic function

  • L2 (float) – Maximum of second logistic function

  • k2 (float) – Steepness of second logistic function

  • x02 (float) – Inflection point of second logistic function

  • a (float) – Offset of double logistic function

Returns:

First derivative of double logistic function with offset at x

Return type:

float or ndarray

dlogistic2_offset_p(x, p)[source]#

Wrapper function for dlogistic2_offset(): dlogistic2_offset(x, *p)

dlogistic_offset(x, L, k, x0, a)[source]#

First derivative of logistic_offset() function

\[L/(1+exp(-k(x-x0))) + a\]

which is

\[k.L/(2(cosh(k(x-x0))+1))\]
Parameters:
  • x (array_like) – Independent variable to evalute derivative of logistic function

  • L (float) – Maximum of logistic function

  • k (float) – Steepness of logistic function

  • x0 (float) – Inflection point of logistic function

  • a (float) – Offset of logistic function

Returns:

First derivative of logistic function with offset at x with maximum L, steepness k, inflection point x0, and offset a

Return type:

float or ndarray

dlogistic_offset_p(x, p)[source]#

Wrapper function for dlogistic_offset(): dlogistic_offset(x, *p)

dlogistic_p(x, p)[source]#

Wrapper function for dlogistic(): dlogistic(x, *p)

logistic(x, L, k, x0)[source]#

Logistic function

\[L/(1+exp(-k(x-x0)))\]
Parameters:
  • x (array_like) – Independent variable to evalute logistic function

  • L (float) – Maximum of logistic function

  • k (float) – Steepness of logistic function

  • x0 (float) – Inflection point of logistic function

Returns:

Logistic function at x with maximum L, steepness k and inflection point x0

Return type:

float or ndarray

logistic2_offset(x, L1, k1, x01, L2, k2, x02, a)[source]#

Double logistic function with offset

\[L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a\]
Parameters:
  • x (array_like) – Independent variable to evalute logistic function

  • L1 (float) – Maximum of first logistic function

  • k1 (float) – Steepness of first logistic function

  • x01 (float) – Inflection point of first logistic function

  • L2 (float) – Maximum of second logistic function

  • k2 (float) – Steepness of second logistic function

  • x02 (float) – Inflection point of second logistic function

  • a (float) – Offset of double logistic function

Returns:

Double Logistic function at x

Return type:

float or ndarray

logistic2_offset_p(x, p)[source]#

Wrapper function for logistic2_offset(): logistic2_offset(x, *p)

logistic_offset(x, L, k, x0, a)[source]#

Logistic function with offset

\[L/(1+exp(-k(x-x0))) + a\]
Parameters:
  • x (array_like) – Independent variable to evalute logistic function

  • L (float) – Maximum of logistic function

  • k (float) – Steepness of logistic function

  • x0 (float) – Inflection point of logistic function

  • a (float) – Offset of logistic function

Returns:

Logistic function at x with maximum L, steepness k, inflection point x0 and offset a

Return type:

float or ndarray

logistic_offset_p(x, p)[source]#

Wrapper function for logistic_offset(): logistic_offset(x, *p)

logistic_p(x, p)[source]#

Wrapper function for logistic(): logistic(x, *p)