比较优化问题中的两种拟合
通常需要比较由 FindFit 生成的两种不同拟合.
model = a Exp[-b (x - c) ^ 2] + d Sin[ω x + ϕ];
data = Table[{x, model /. {a -> 2, b -> 1, c -> 0, d -> 2, ω -> 0.67, ϕ -> 0.1}}, {x, -5, 5, .1}] + RandomReal[.25, 101];f1 = FindFit[data, model, {a, b, c, d, ω, ϕ}, x]f2 = FindFit[data, model, {a, b, {c, 0}, d, ω, ϕ}, x]Show[Plot[Evaluate[model /. {f1, f2}], {x, -5, 5}, PlotStyle -> {Red, Blue}], ListPlot[data, PlotRange -> All, PlotStyle -> Gray]]