from typing import Callable
import math


def logistic(A, K, B, v, Q, M) -> Callable[[float], float]:
    """
    Creates a generalized logistic function. https://en.wikipedia.org/wiki/Generalised_logistic_function

    :param A: the lower asymptote
    :param K: the upper asymptote
    :param B: the growth rate
    :param v: near which asymptote the growth occurs
    :param Q: Y(0)
    :param M: starting point x_0
    :return: a function
    """

    def f(t):
        return A + (K - A) / ((1 + Q * math.exp(-B * (t - M))) ** (1 / v))

    return f