# Revision history [back]

To obtain the version of the model with the "best fit" for the parameters found by find_fit, use subs.

If that was not the question, can you clarify it?

Example of applying subs to the result of find_fit:

sage: R = [[0, 1], [4, 2], [8, 4], [12, 8], [16, 16],
....:      [20, 32], [24, 64], [28, 128], [32, 256]]
sage: p = scatter_plot(R)

sage: a = var('a')
sage: model(x) = 2^(a*x)
sage: fit = find_fit(R, model)

sage: f(x) = model(x).subs(fit)
sage: f
x |--> 2^(0.25*x)

sage: a, b = SR.var('a, b')
sage: model(x) = a^(b*x)
sage: fit = find_fit(R, model)
sage: fit
[a == 1.1017948048163804, b == 1.7875584659241468]

sage: g(x) = model(x).subs(fit)
sage: g
x |--> 1.1017948048163804^(1.7875584659241468*x)