Skip to content

numerical/utils.py

linear_model

linear_model(x: float | NDArray, m: float, c: float) -> float | NDArray

Simple linear model of form: \(y = m x + c\).

Parameters:

Returns:

Source code in wmbe/numerical/utils.py
def linear_model(
        x: float|NDArray, 
        m: float, 
        c: float,
    ) -> float|NDArray:
    """
    Simple linear model of form: $y = m x + c$.

    Args:
        x: coordinate
        m: gradient
        c: intercept

    Returns:
        y
    """    
    return m*x+c

exponential_decay_model

exponential_decay_model(x: float | NDArray, m: float, c: float) -> float | NDArray

Shifted exponential decay model of form: \(y = 1 + c \exp(-x/m)\).

Parameters:

Returns:

Source code in wmbe/numerical/utils.py
def exponential_decay_model(
        x: float|NDArray, 
        m: float, 
        c: float,
    ) -> float|NDArray:
    """
    Shifted exponential decay model of form: $y = 1 + c \\exp(-x/m)$.

    Args:
        x: coordinate
        m: e-folding scale
        c: magnitude

    Returns:
        y
    """    
    return 1 + c*np.exp(-x/m)