Function module#

Provides a variety of special functions, including common test functions for parameter estimations such as Rosenbrock and Griewank, test functions for parameter sensitivity analysis such as the Ishigami and Homma function, several forms of the logistic function and its first and second derivatives, and a variety of other functions together with robust and square cost functions to use with the scipy.optimize package.

copyright:

Copyright 2014-2021 Matthias Cuntz, see AUTHORS.rst for details.

license:

MIT License, see LICENSE for details.

Subpackages#

general_functions

General functions that are not specialised for fitting, optimisation, sensitivity analysis, etc.

fit_functions

Common functions used in scipy's curve_fit or minimize parameter estimations.

logistic_function

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

opti_test_functions

Common test functions for parameter estimation and optimisation algorithms.

sa_test_functions

Test functions for parameter sensitivity analysis.

B(X)[source]#

B function

Saltelli et al. (2010) Comp. Phys. Comm. 181, p. 259-270

Parameters:

X (array_like) – (nX,) or (nX,npoints) array of floats

Returns:

B – float or (npoints,) floats of B function values at X

Return type:

float or ndarray

G(X, a)[source]#

G-function

Sobol’ (1990) Matematicheskoe Modelirovanie 2, 112-118 (in Russian)

Sobol’ (1993) Mathematical Modelling and Computational Experiment 1, 407-414 (English translation)

Parameters:
  • X (array_like) – (nX,) or (nX,npoints) array of floats

  • a (array_like) – (nX,) array of floats

Returns:

g – float or (npoints,) floats of G function values at X with parameters a

Return type:

float or ndarray

Gstar(X, alpha, delta, a)[source]#

G* example

Saltelli et al. (2010) Comp. Phys. Comm., 181, p. 259-270

Parameters:
  • X (array_like) – (nX,) or (nX,npoints) array of floats

  • alpha (array_like) – (nX,) array of floats

  • delta (array_like) – (nX,) array of floats

  • a (array_like) – (nX,) array of floats

Returns:

G* – float or (npoints,) floats of G* function values at X with parameters alpha, delta and a

Return type:

float or ndarray

K(X)[source]#

K example

Saltelli et al. (2010) Comp. Phys. Comm., 181, p. 259-270

Parameters:

X (array_like) – (nX,) or (nX,npoints) array of floats

Returns:

K – float or (npoints,) floats of K function values at X

Return type:

float or ndarray

ackley(x)[source]#

Ackley function (>= 2-D).

Global Optimum: 0.0 at origin.

Parameters:

x (array) – multi-dimensional x-values (len(x) >= 2)

Returns:

Value of Ackley function.

Return type:

float

arrhenius(T, E)[source]#

Arrhenius temperature dependence of rates

Parameters:
  • T (float or array_like of floats) – temperature [degC]

  • E (float) – activation energy [J]

Returns:

function value(s)

Return type:

float

arrhenius_p(T, p)[source]#

Arrhenius temperature dependence of rates

Parameters:
  • T (float or array_like of floats) – temperature [degC]

  • p (iterable) – p[0] = activation energy [J]

Returns:

function value(s)

Return type:

float

bratley(*args)[source]#

K example

Saltelli et al. (2010) Comp. Phys. Comm., 181, p. 259-270

Parameters:

X (array_like) – (nX,) or (nX,npoints) array of floats

Returns:

bratley – float or (npoints,) floats of K function values at X

Return type:

float or ndarray

cost2_arrhenius(p, T, rate)[source]#

Sum of squared deviations of obs and arrhenius function

Parameters:
  • p (iterable of floats) – p[0] = activation energy [J]

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_f1x(p, x, y)[source]#

Sum of squared deviations of obs and general 1/x function: \(a + b/x\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_fexp(p, x, y)[source]#

Sum of squared deviations of obs and general exponential function: \(a + b * exp(c*x)\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = a

    • p[1] = b

    • p[2] = c

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_gauss(p, x, y)[source]#

Sum of squared deviations of obs and Gauss function: \(1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = mean mu

    • p[1] = width sig

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_lasslop(p, Rg, et, VPD, NEE)[source]#

Sum of squared deviations of obs and Lasslop et al (2010)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)
    • p[0] = Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

    • p[1] = Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

    • p[2] = e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

    • p[3] = Respiration at Tref (10 degC) [umol(C) m-2 s-1]

  • Rg (float or array_like of floats) – Global radiation [W m-2]

  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []

  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]

  • NEE (float or array_like of floats) – Observed net ecosystem exchange [umol(CO2) m-2 s-1]

Returns:

sum of squared deviations

Return type:

float

cost2_line(p, x, y)[source]#

Sum of squared deviations of obs and straight line: \(a + b*x\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_line0(p, x, y)[source]#

Sum of squared deviations of obs and straight line through origin: \(a*x\)

Parameters:
  • p (iterable of floats) – p[0] = a

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_lloyd_fix(p, T, resp)[source]#

Sum of squared deviations of obs and Lloyd & Taylor (1994) Arrhenius type.

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = Respiration at Tref=10 degC [umol(C) m-2 s-1]

    • p[1] = Activation energy [K]

  • T (float or array_like of floats) – Temperature [K]

  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]

Returns:

sum of squared deviations

Return type:

float

cost2_lloyd_only_rref(p, et, resp)[source]#

Sum of squared deviations of obs and Lloyd & Taylor with fixed E0

Parameters:
  • p (iterable of floats) – p[0] = Respiration at Tref=10 degC [umol(C) m-2 s-1]

  • et (float or array_like of floats) – exp-term in Lloyd & Taylor

  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]

Returns:

sum of squared deviations

Return type:

float

cost2_logistic(p, x, y)[source]#

Sum of squared deviations of obs and logistic function \(L/(1+exp(-k(x-x0)))\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = L = Maximum of logistic function

    • p[1] = k = Steepness of logistic function

    • p[2] = x0 = Inflection point of logistic function

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_logistic2_offset(p, x, y)[source]#

Sum of squared deviations of obs and double logistic function with offset: \(L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=7)
    • p[0] = L1 = Maximum of first logistic function

    • p[1] = k1 = Steepness of first logistic function

    • p[2] = x01 = Inflection point of first logistic function

    • p[3] = L2 = Maximum of second logistic function

    • p[4] = k2 = Steepness of second logistic function

    • p[5] = x02 = Inflection point of second logistic function

    • p[6] = a = Offset of double logistic function

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_logistic_offset(p, x, y)[source]#

Sum of squared deviations of obs and logistic function 1/x function: \(L/(1+exp(-k(x-x0))) + a\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)
    • p[0] = L = Maximum of logistic function

    • p[1] = k = Steepness of logistic function

    • p[2] = x0 = Inflection point of logistic function

    • p[3] = a = Offset of logistic function

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_poly(p, x, y)[source]#

Sum of squared deviations of obs and general polynomial: \(c0 + c1*x + c2*x**2 + ... + cn*x**n\)

Parameters:
  • p (iterable of floats) – parameters (len(p)=n+1)

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_sabx(p, x, y)[source]#

Sum of squared deviations of obs and square root of general 1/x function: \(sqrt(a + b/x)\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost2_see(p, x, y)[source]#

Sum of squared deviations of obs and fit function of Sequential Elementary Effects: \(a * (x-b)**c\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = a

    • p[1] = b

    • p[2] = c

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

cost_abs(p, func, x, y)[source]#

General cost function for robust optimising func(x, p) vs y with sum of absolute deviations.

Parameters:
  • p (iterable of floats) – parameters

  • func (callable) – fun(x,p) -> float

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_arrhenius(p, T, rate)[source]#

Sum of absolute deviations of obs and arrhenius function

Parameters:
  • p (iterable of floats) – p[0] = activation energy [J]

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_f1x(p, x, y)[source]#

Sum of absolute deviations of obs and general 1/x function: \(a + b/x\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_fexp(p, x, y)[source]#

Sum of absolute deviations of obs and general exponential function: \(a + b * exp(c*x)\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = a

    • p[1] = b

    • p[2] = c

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_gauss(p, x, y)[source]#

Sum of absolute deviations of obs and Gauss function: \(1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = mean mu

    • p[1] = width sig

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_lasslop(p, Rg, et, VPD, NEE)[source]#

Sum of absolute deviations of obs and Lasslop et al (2010)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)
    • p[0] = Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

    • p[1] = Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

    • p[2] = e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

    • p[3] = Respiration at Tref (10 degC) [umol(C) m-2 s-1]

  • Rg (float or array_like of floats) – Global radiation [W m-2]

  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []

  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]

  • NEE (float or array_like of floats) – Observed net ecosystem exchange [umol(CO2) m-2 s-1]

Returns:

sum of absolute deviations

Return type:

float

cost_line(p, x, y)[source]#

Sum of absolute deviations of obs and straight line: \(a + b*x\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_line0(p, x, y)[source]#

Sum of absolute deviations of obs and straight line through origin: \(a*x\)

Parameters:
  • p (iterable of floats) – p[0] = a

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_lloyd_fix(p, T, resp)[source]#

Sum of absolute deviations of obs and Lloyd & Taylor (1994) Arrhenius type.

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = Respiration at Tref=10 degC [umol(C) m-2 s-1]

    • p[1] = Activation energy [K]

  • T (float or array_like of floats) – Temperature [K]

  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]

Returns:

sum of absolute deviations

Return type:

float

cost_lloyd_only_rref(p, et, resp)[source]#

Sum of absolute deviations of obs and Lloyd & Taylor with fixed E0

Parameters:
  • p (iterable of floats) – p[0] = Respiration at Tref=10 degC [umol(C) m-2 s-1]

  • et (float or array_like of floats) – exp-term in Lloyd & Taylor

  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]

Returns:

sum of absolute deviations

Return type:

float

cost_logistic(p, x, y)[source]#

Sum of absolute deviations of obs and logistic function \(L/(1+exp(-k(x-x0)))\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = L = Maximum of logistic function

    • p[1] = k = Steepness of logistic function

    • p[2] = x0 = Inflection point of logistic function

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_logistic2_offset(p, x, y)[source]#

Sum of absolute deviations of obs and double logistic function with offset: \(L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=7)
    • p[0] = L1 = Maximum of first logistic function

    • p[1] = k1 = Steepness of first logistic function

    • p[2] = x01 = Inflection point of first logistic function

    • p[3] = L2 = Maximum of second logistic function

    • p[4] = k2 = Steepness of second logistic function

    • p[5] = x02 = Inflection point of second logistic function

    • p[6] = a = Offset of double logistic function

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_logistic_offset(p, x, y)[source]#

Sum of absolute deviations of obs and logistic function 1/x function: \(L/(1+exp(-k(x-x0))) + a\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)
    • p[0] = L = Maximum of logistic function

    • p[1] = k = Steepness of logistic function

    • p[2] = x0 = Inflection point of logistic function

    • p[3] = a = Offset of logistic function

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_poly(p, x, y)[source]#

Sum of absolute deviations of obs and general polynomial: \(c0 + c1*x + c2*x**2 + ... + cn*x**n\)

Parameters:
  • p (iterable of floats) – parameters (len(p)=n+1)

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_sabx(p, x, y)[source]#

Sum of absolute deviations of obs and square root of general 1/x function: \(sqrt(a + b/x)\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_see(p, x, y)[source]#

Sum of absolute deviations of obs and fit function of Sequential Elementary Effects: \(a * (x-b)**c\)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = a

    • p[1] = b

    • p[2] = c

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of absolute deviations

Return type:

float

cost_square(p, func, x, y)[source]#

General cost function for optimising func(x, p) vs y with sum of square deviations.

Parameters:
  • p (iterable of floats) – parameters

  • func (callable) – fun(x,p) -> float

  • x (float or array_like of floats) – independent variable

  • y (float or array_like of floats) – dependent variable, observations

Returns:

sum of squared deviations

Return type:

float

curvature(x, dfunc, d2func, *args, **kwargs)[source]#

Curvature of a function f

\[f''/(1+f'^2)^{3/2}\]
Parameters:
  • x (array_like) – Independent variable to evalute curvature

  • dfunc (callable) – Function giving first derivative of function f: f’, to be called dfunc(x, *args, **kwargs)

  • d2func (callable) – Function giving second derivative of function f: f’’, to be called d2func(x, *args, **kwargs)

  • args (iterable) – Arguments passed to dfunc and d2func

  • kwargs (dict) – Keyword arguments passed to dfunc and d2func

Returns:

Curvature of function f at x

Return type:

float or ndarray

Examples

from pyjams.functions import dlogistic_offset, d2logistic_offset
curvature(1., dlogistic_offset, d2logistic_offset,
          [1., 2., 2., 1.])
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)

f1x(x, a, b)[source]#

General 1/x function: \(a + b/x\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • a (float) – first parameter

  • b (float) – second parameter

Returns:

function value(s)

Return type:

float

f1x_p(x, p)[source]#

General 1/x function: \(a + b/x\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

Returns:

function value(s)

Return type:

float

fexp(x, a, b, c)[source]#

General exponential function: \(a + b * exp(c*x)\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • a (float) – first parameter

  • b (float) – second parameter

  • c (float) – third parameter

Returns:

function value(s)

Return type:

float

fexp_p(x, p)[source]#

General exponential function: \(a + b * exp(c*x)\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = a

    • p[1] = b

    • p[2] = c

Returns:

function value(s)

Return type:

float

fmorris(X, beta0, beta1, beta2, beta3, beta4)[source]#

Morris-function

Morris (1991) Technometrics 33, 161-174

Parameters:
  • X (array_like) – (20,) or (20,npoints) array of floats

  • beta0 (float) – float

  • beta1 (array_like) – (20,) array of floats

  • beta2 (array_like) – (20,20) array of floats

  • beta3 (array_like) – (20,20,20) array of floats

  • beta4 (array_like) – (20,20,20,20) array of floats

Returns:

fmorris – float or (npoints,) floats of Morris function values at X with parameters beta0-beta4

Return type:

float or ndarray

g(X, a)[source]#

G-function

Sobol’ (1990) Matematicheskoe Modelirovanie 2, 112-118 (in Russian)

Sobol’ (1993) Mathematical Modelling and Computational Experiment 1, 407-414 (English translation)

Parameters:
  • X (array_like) – (nX,) or (nX,npoints) array of floats

  • a (array_like) – (nX,) array of floats

Returns:

G – float or (npoints,) floats of G function values at X with parameters a

Return type:

float or ndarray

gauss(x, mu, sig)[source]#

Gauss function: \(1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • mu (float) – mean

  • sig (float) – width

Returns:

function value(s)

Return type:

float

gauss_p(x, p)[source]#

Gauss function: \(1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = mean mu

    • p[1] = width sig

Returns:

function value(s)

Return type:

float

goldstein_price(x)[source]#

Goldstein-Price function (2-D).

Global Optimum: 3.0 at (0.0, -1.0).

Parameters:

x (array) – 2 x-values. len(x)=2. x[i] bound to [-2, 2] for i=1 and 2.

Returns:

Value of Goldstein-Price function.

Return type:

float

griewank(x)[source]#

Griewank function (2-D or 10-D).

Global Optimum: 0.0 at origin.

Parameters:

x (array) – multi-dimensional x-values. len(x)=2 or len(x)=10. x[i] bound to [-600, 600] for all i.

Returns:

Value of Griewank function.

Return type:

float

ishigami_homma(X, a, b)[source]#

Ishigami and Homma (1990)

given by Saltelli et al. (2008, page 179)

Parameters:
  • X (array_like) – (3,) or (3,npoints) array of floats

  • a (array_like) – float or (npoints,) array of floats

  • b (array_like) – float or (npoints,) array of floats

Returns:

ishigami_homma – float or (npoints,) floats of Ishigami and Homma function values at X with parameters a and b

Return type:

float or ndarray

ishigami_homma_easy(X)[source]#

Simplified Ishigami and Homma function

\[Y = sin(X[0]) + X[1]\]

with X[0], X[1] ~ Uniform[-Pi, Pi]

Parameters:

X (array_like) – (2,) or (2,npoints) array of floats

Returns:

ishigami_homma_easy – float or (npoints,) floats of simplified Ishigami and Homma function values at X

Return type:

float or ndarray

lasslop(Rg, et, VPD, alpha, beta0, k, Rref)[source]#

NEE of Lasslop et al (2010)

Lasslop et al. (2010) is the rectangular, hyperbolic light-response of NEE as by Falge et al. (2001), where the respiration is calculated with Lloyd & Taylor (1994), and the maximum canopy uptake rate at light saturation decreases exponentially with VPD as in Koerner (1995).

Parameters:
  • Rg (float or array_like of floats) – Global radiation [W m-2]

  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []

  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]

  • alpha (float) – Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

  • beta0 (float) – Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

  • k (float) – e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

  • Rref (float) – Respiration at Tref (10 degC) [umol(C) m-2 s-1]

Returns:

net ecosystem exchange [umol(CO2) m-2 s-1]

Return type:

float

lasslop_p(Rg, et, VPD, p)[source]#

NEE of Lasslop et al (2010)

Lasslop et al. (2010) is the rectangular, hyperbolic light-response of NEE as by Falge et al. (2001), where the respiration is calculated with Lloyd & Taylor (1994), and the maximum canopy uptake rate at light saturation decreases exponentially with VPD as in Koerner (1995).

Parameters:
  • Rg (float or array_like of floats) – Global radiation [W m-2]

  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []

  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]

  • p (iterable of floats) –

    parameters (len(p)=4)
    • p[0] = Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

    • p[1] = Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

    • p[2] = e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

    • p[3] = Respiration at Tref (10 degC) [umol(C) m-2 s-1]

Returns:

net ecosystem exchange [umol(CO2) m-2 s-1]

Return type:

float

line(x, a, b)[source]#

Straight line: \(a + b*x\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • a (float) – first parameter

  • b (float) – second parameter

Returns:

function value(s)

Return type:

float

line0(x, a)[source]#

Straight line through origin: \(a*x\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • a (float) – first parameter

Returns:

function value(s)

Return type:

float

line0_p(x, p)[source]#

Straight line through origin: \(a*x\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) – p[0] = a

Returns:

function value(s)

Return type:

float

line_p(x, p)[source]#

Straight line: \(a + b*x\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

Returns:

function value(s)

Return type:

float

linear(X, a, b)[source]#

Linear test function

\[Y = a*X + b\]
Parameters:
  • X (array_like) – (1,) or (1,npoints) array of floats

  • a (array_like) – float or (npoints,) array of floats

  • b (array_like) – float or (npoints,) array of floats

Returns:

linear – float or (npoints,) floats of linear function values at X with parameters a and b

Return type:

float or ndarray

lloyd_fix(T, Rref, E0)[source]#

Soil respiration of Lloyd & Taylor (1994)

Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC

Parameters:
  • T (float or array_like of floats) – Temperature [K]

  • Rref (float) – Respiration at Tref=10 degC [umol(C) m-2 s-1]

  • E0 (float) – Activation energy [K]

Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

lloyd_fix_p(T, p)[source]#

Soil respiration of Lloyd & Taylor (1994)

Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC

Parameters:
  • T (float or array_like of floats) – Temperature [K]

  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = Respiration at Tref=10 degC [umol(C) m-2 s-1]

    • p[1] = Activation energy [K]

Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

lloyd_only_rref(et, Rref)[source]#

Soil respiration of Lloyd & Taylor (1994) with fix E0

If E0 is know in Lloyd & Taylor (1994) then one can calc the exponential term outside the routine and the fitting becomes linear. One could also use functions.line0.

Parameters:
  • et (float or array_like of floats) – exp-term in Lloyd & Taylor

  • Rref (float) – Respiration at Tref=10 degC [umol(C) m-2 s-1]

Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

lloyd_only_rref_p(et, p)[source]#

Soil respiration of Lloyd & Taylor (1994) with fix E0

If E0 is know in Lloyd & Taylor (1994) then one can calc the exponential term outside the routine and the fitting becomes linear. One could also use functions.line0.

Parameters:
  • et (float or array_like of floats) – exp-term in Lloyd & Taylor

  • p (iterable of floats) – p[0] = Respiration at Tref=10 degC [umol(C) m-2 s-1]

Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

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)

morris(*args)[source]#

Morris-function

Morris (1991) Technometrics 33, 161-174

Parameters:
  • X (array_like) – (20,) or (20, npoints) array of floats

  • beta0 (float) – float

  • beta1 (array_like) – (20,) array of floats

  • beta2 (array_like) – (20, 20) array of floats

  • beta3 (array_like) – (20, 20, 20) array of floats

  • beta4 (array_like) – (20, 20, 20, 20) array of floats

Returns:

morris – float or (npoints,) floats of Morris function values at X with parameters beta0-beta4

Return type:

float or ndarray

oakley_ohagan(X)[source]#

Oakley and O’Hagan (2004)

    1. Statist. Soc. B 66, Part 3, 751-769

Parameters:

X (array_like) – (15,) or (15, npoints) array of floats

Returns:

oakley_ohagan – float or (npoints,) floats of Oakley and O’Hagan function values at X

Return type:

float or ndarray

poly(x, *args)[source]#

General polynomial: \(c0 + c1*x + c2*x**2 + ... + cn*x**n\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • *args (float) – parameters len(args)=n+1

Returns:

function value(s)

Return type:

float

poly_p(x, p)[source]#

General polynomial: \(c0 + c1*x + c2*x**2 + ... + cn*x**n\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) – parameters (len(p)=n+1)

Returns:

function value(s)

Return type:

float

product(X)[source]#

Product test function

\[Y = X[0] * X[1]\]
Parameters:

X (array_like) – (2,) or (2,npoints) array of floats

Returns:

product – float or (npoints,) floats of product function values at X

Return type:

float or ndarray

rastrigin(x)[source]#

Rastrigin function (2-D).

Global Optimum: -2.0 at origin.

Parameters:

x (array) – 2 x-values. len(x)=2. x[i] bound to [-1, 1] for i=1 and 2.

Returns:

Value of Rastrigin function.

Return type:

float

ratio(X)[source]#

Ratio test function

\[Y = X[0] / X[1]\]

Simple nonlinear model proposed by Liu et al. (2006):

Liu, H., Sudjianto, A., Chen, W., 2006. Relative entropy based method for probabilistic sensitivity analysis in engineering design. J. Mech. Des. 128, 326-336.

Used by Pianosi & Wagener, Environmental Modelling & Software (2015)

Pianosi, F. & Wagener T., 2015 A simple and efficient method for global sensitivity analysis based on cumulative distribution functions. Environmental Modelling & Software 67, 1-11.

Parameters:

X (array_like) – (2,) or (2,npoints) array of floats

Returns:

ratio – float or (npoints,) floats of ratio function values at X

Return type:

float or ndarray

rosenbrock(x)[source]#

Rosenbrock function (2-D).

Global Optimum: 0.0 at (1.0, 1.0).

Parameters:

x (array) – 2 x-values. len(x)=2. x[1] bound to [-5, 5]. x[2] bound to [-2, 8].

Returns:

Value of Rosenbrock function.

Return type:

float

sabx(x, a, b)[source]#

Square root of general 1/x function: \(sqrt(a + b/x)\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • a (float) – first parameter

  • b (float) – second parameter

Returns:

function value(s)

Return type:

float

sabx_p(x, p)[source]#

Square root of general 1/x function: \(sqrt(a + b/x)\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) –

    parameters (len(p)=2)
    • p[0] = a

    • p[1] = b

Returns:

function value(s)

Return type:

float

see(x, a, b, c)[source]#

Fit function of Sequential Elementary Effects: \(a * (x-b)**c\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • a (float) – first parameter

  • b (float) – second parameter

  • c (float) – third parameter

Returns:

function value(s)

Return type:

float

see_p(x, p)[source]#

Fit function of Sequential Elementary Effects: \(a * (x-b)**c\)

Parameters:
  • x (float or array_like of floats) – independent variable

  • p (iterable of floats) –

    parameters (len(p)=3)
    • p[0] = a

    • p[1] = b

    • p[2] = c

Returns:

function value(s)

Return type:

float

six_hump_camelback(x)[source]#

Six-hump Camelback function (2-D).

Global Optima: -1.031628453489877 at (-0.08983, 0.7126) and (0.08983, -0.7126).

Parameters:

x (array) – 2 x-values. len(x)=2. x[i] bound to [-5, 5] for i=1 and 2.

Returns:

Value of Six-hump Camelback function.

Return type:

float