Пример #1
0
def test_stochastic():
    # Case 1
    # ------

    noise = 1.
    tau = 10.

    def int_m(m, t, V):
        alpha = 0.1 * (V + 40) / (1 - np.exp(-(V + 40) / 10))
        beta = 4.0 * np.exp(-(V + 65) / 18)
        return alpha * (1 - m) - beta * m, noise / beta

    diff_eq = DiffEquation(int_m)
    assert diff_eq.is_stochastic is True

    # Case 2
    # ------

    noise = 0.
    tau = 10.

    def int_m(m, t, V):
        alpha = 0.1 * (V + 40) / (1 - np.exp(-(V + 40) / 10))
        beta = 4.0 * np.exp(-(V + 65) / 18)
        return alpha * (1 - m) - beta * m, noise / beta

    diff_eq = DiffEquation(int_m)
    assert diff_eq.is_stochastic is True

    # Case 3
    # ------

    noise = 0.
    tau = 10.

    def int_m(m, t, V):
        alpha = 0.1 * (V + 40) / (1 - np.exp(-(V + 40) / 10))
        beta = 4.0 * np.exp(-(V + 65) / 18)
        return alpha * (1 - m) - beta * m, noise / tau

    diff_eq = DiffEquation(int_m)
    assert diff_eq.is_stochastic is False

    # Case 4
    # ------

    noise = 1.
    tau = 10.

    def int_m(m, t, V):
        alpha = 0.1 * (V + 40) / (1 - np.exp(-(V + 40) / 10))
        beta = 4.0 * np.exp(-(V + 65) / 18)
        return alpha * (1 - m) - beta * m, noise / tau

    diff_eq = DiffEquation(int_m)
    assert diff_eq.is_stochastic is True
Пример #2
0
def try_analyse_func():
    import numpy as np

    def int_m(m, t, V):
        alpha = 0.1 * (V + 40) / (1 - np.exp(-(V + 40) / 10))
        beta = 4.0 * np.exp(-(V + 65) / 18)
        return alpha * (1 - m) - beta * m, (alpha, beta)

    from pprint import pprint

    df = DiffEquation(int_m)
    pprint(df.expressions)
    pprint(df.returns)
    pprint(df.get_f_expressions())
    pprint(df.get_g_expressions())
    print('-'* 30)
Пример #3
0
def try_analyse_func3():
    def g_func(m, t):
        a = t + 2
        b = m + 6
        c = a + b
        d = m * 2 + c
        return d

    from pprint import pprint

    df = DiffEquation(func=None, g=g_func)
    pprint(df.expressions)
    pprint(df.returns)
    pprint(df.get_f_expressions())
    pprint(df.get_g_expressions())
    print('-' * 30)
Пример #4
0
def try_analyse_func2():
    def func(m, t):
        a = t + 2
        b = m + 6
        c = a + b
        d = m * 2 + c
        return d, c

    from pprint import pprint

    df = DiffEquation(func=func, g=np.zeros(10))
    pprint(df.expressions)
    pprint(df.returns)
    pprint(df.get_f_expressions())
    pprint(df.get_g_expressions())
    print('-' * 30)