Exemplo n.º 1
0
def summarize(d):
    print('newton delta:')
    print(arbplf_newton_delta(json.dumps(d)))
    print('deriv:')
    print(arbplf_deriv(json.dumps(d)))
    print('ll:')
    print(arbplf_ll(json.dumps(d)))
Exemplo n.º 2
0
def myderiv(d):
    """
    Provides a dict -> pandas.DataFrame wrapper of the pure JSON arbplf_deriv.
    """
    s = arbplf_deriv(json.dumps(d))
    df = pd.read_json(StringIO(s), orient='split', precise_float=True)
    return df
Exemplo n.º 3
0
def summarize(d):
    print('newton delta:')
    print(arbplf_newton_delta(json.dumps(d)))
    print('deriv:')
    print(arbplf_deriv(json.dumps(d)))
    print('ll:')
    print(arbplf_ll(json.dumps(d)))
def test_truncated_deriv():
    d = copy.deepcopy(D)
    d['model_and_data']['probability_array'][0][-1] = [0, 1]
    s = arbplf_deriv(json.dumps(d))
    df = pd.read_json(StringIO(s), orient='split', precise_float=True)
    actual = df.set_index('edge').value.values
    # compute the desired closed form solution
    T = sum(rates)
    # derivative of log(1 - exp(-T))
    desired = np.reciprocal(expm1(T))
    # compare actual and desired result
    assert_allclose(actual, desired)
Exemplo n.º 5
0
def generic_objective(get_s, X):
    s_in = get_s(X)
    neg_ll = partial(generic_neg_ll, get_s)

    # compute negative log likelihood
    s_out = arbplf_ll(s_in)
    df = pd.read_json(StringIO(s_out), orient='split', precise_float=True)
    y = -df.value.values[0]

    # explicitly compute derivatives with respect to edge rate coefficients
    s_out = arbplf_deriv(s_in)
    df = pd.read_json(StringIO(s_out), orient='split', precise_float=True)
    d = -df.set_index('edge').value.values

    edge_count = len(_edges)
    D = np.concatenate((d, [0]*3))
    request = np.array([0]*edge_count + [1]*3)
    _finite_diffs(neg_ll, request, D, X, y)
    print(y, D)
    return y, D
Exemplo n.º 6
0
def myderiv(d):
    s = arbplf_deriv(json.dumps(d))
    df = pd.read_json(StringIO(s), orient="split", precise_float=True)
    return df
Exemplo n.º 7
0
def myderiv(d):
    s = arbplf_deriv(json.dumps(d))
    df = pd.read_json(StringIO(s), orient='split', precise_float=True)
    return df