Example #1
0
def test_fit_engine_list():
    a = 1
    b = 2
    c = 3
    m = quadratic_model('',
                        a, 'free', [-1, 1],
                        b, 'free', [-1, 1],
                        c, 'free', [-1, 1])
    x = np.arange(-1, 1, 0.01)
    y = x**2 + 1

    datav = [(x, y), (x, y+2)]
    out = fit_engine_list(m, datav)
    assert_equal(len(out), 2)
Example #2
0
def test_quadratic_fit():
    x = np.arange(-1, 1, .01)
    a = 1
    b = 2
    c = 3

    true_val = [a, b, c]

    y = a * x*x + b * x + c

    m = quadratic_model('',
                        a, 'free', [-1, 1],
                        b, 'free', [-1, 1],
                        c, 'free', [-1, 1])

    result, yfit = fit_engine(m, x, y)
    out = result.values
    fitted_val = (out['a'], out['b'], out['c'])
    assert_array_almost_equal(true_val, fitted_val)