Skip to content

func

Provide common functions like a linear function \(m * x + b\).

exp(x, k, a, b)

Exponential function \( y = a \times \exp(k \times x) + b \)

Parameters:

Name Type Description Default
x

x

required
k

grow rate

required
a

Start value

required
b

y-offset

required
Source code in src/labeva/func.py
def exp(x, k, a, b):
    """
    Exponential function
    \\( y = a \\times \\exp(k \\times x) + b \\)

    Args:
        x: x
        k: grow rate
        a: Start value
        b: y-offset
    """
    return a * np.exp(k * x) + b

exp_decay(t, tau, a, b)

Exponential function \( y = a \times \exp(\tau \times t) + b \)

Parameters:

Name Type Description Default
t

t

required
tau

decay time

required
a

Start value

required
b

y-offset

required
Source code in src/labeva/func.py
def exp_decay(t, tau, a, b):
    """
    Exponential function
    \\( y = a \\times \\exp(\\tau \\times t) + b \\)

    Args:
        t: t
        tau: decay time
        a: Start value
        b: y-offset
    """
    return a * np.exp(-t / tau) + b

gauss(x, x0, std, a0, b)

Gaussian distribution

Parameters:

Name Type Description Default
x

x

required
x0

expected value \(\mu\)

required
std

standard derivation \(\sigma\)

required
a0

Peak height

required
b

y-offset

required
Source code in src/labeva/func.py
def gauss(x, x0, std, a0, b):
    """
    Gaussian distribution

    Args:
        x: x
        x0: expected value \\(\\mu\\)
        std: standard derivation \\(\\sigma\\)
        a0: Peak height
        b: y-offset
    """
    return a0 * np.exp(-((x - x0) ** 2) / (2 * std**2)) + b

gauss_normalized(x, x0, std)

Normalized gaussian distribution

Parameters:

Name Type Description Default
x

x

required
x0

expected value \(\mu\)

required
std

standard derivation \(\sigma\)

required
Source code in src/labeva/func.py
def gauss_normalized(x, x0, std):
    """
    Normalized gaussian distribution

    Args:
        x: x
        x0: expected value \\(\\mu\\)
        std: standard derivation \\(\\sigma\\)
    """
    return gauss(x, x0, std, 1 / (std * np.sqrt(2 * np.pi)), 0)

lin(x, m, b)

linear function

Parameters:

Name Type Description Default
x

x

required
m

slope

required
b

y-offset

required
Source code in src/labeva/func.py
def lin(x, m, b):
    """
    linear function

    Args:
        x: x
        m: slope
        b: y-offset
    """
    return m * x + b

ln(x, tau, a, b)

logarithmic function \( y = \tau \times \ln\left(\frac{x - b}{a}\right) \) inverse of exponential function with \(\tau = 1/k_{exp}\)

Parameters:

Name Type Description Default
x

x

required
tau

stretching factor

required
a

Start value of exp

required
b

y-offset of exp

required
Source code in src/labeva/func.py
def ln(x, tau, a, b):
    """
    logarithmic function
    \\( y = \\tau \\times \\ln\\left(\\frac{x - b}{a}\\right) \\)
    inverse of exponential function with \\(\\tau = 1/k_{exp}\\)

    Args:
        x: x
        tau: stretching factor
        a: Start value of exp
        b: y-offset of exp
    """
    return tau * np.log((x - b) / a)  # tau = 1/k from expfunc

polynom(x, *args)

Polynomial function with arbitrary order \( y = a_0 x + a_1 x + a_2 x + \dots \)

Parameters:

Name Type Description Default
x

x

required
*args

\(a_i\)

()
Source code in src/labeva/func.py
def polynom(x, *args):
    """
    Polynomial function with arbitrary order
    \\( y = a_0 x + a_1 x + a_2 x + \\dots \\)

    Args:
        x: x
        *args: \\(a_i\\)
    """
    return sum([args[i] * x**i for i in range(len(args))])

quad(x, a, x0, y0)

Parabel function

Parameters:

Name Type Description Default
x

x

required
a

stretching factor

required
x0

x-offset

required
y0

y-offset

required
Source code in src/labeva/func.py
def quad(x, a, x0, y0):
    """
    Parabel function

    Args:
        x: x
        a: stretching factor
        x0: x-offset
        y0: y-offset
    """
    return a * (x - x0) ** 2 + y0