In functions like NonlinearModelFit
I need to specify parameters with a symbol name. If I localize these parameters they get cluttered in the output (e.g."ParameterTable"
):
{a, b, c, d} = {2, 30, 4, 0};
data = a PDF[NormalDistribution[b, c], Range@100] +
RandomReal[{-.01, .01}, 100];
fitFunc[a_, b_, c_, d_, x_] := a PDF[NormalDistribution[b, c], x] + d
fit[data_] := Module[{a, b, c, d, aStart, nlmf},
aStart = Max@data;
nlmf = NonlinearModelFit[data,
fitFunc[a, b, c, d, x], {{a, aStart}, {b, 30}, {c, 4}, {d, 0}}, x];
nlmf["ParameterTable"]
]
fit@data
How can I avoid outputs like a$18554
in the the ParameterTable without using global symbol names for the parameters a, b, c, d inside NonlinearModelFit
?
Block
in place ofModule
. The parameters will all be renamed to things likeTransformedParameter$4
but will still display as the original symbols. $\endgroup$ – Oleksandr R. Feb 5 '13 at 15:53fit[data_,vars_] := Module[...]
where you then usevars
explicitly in theModule
. $\endgroup$ – Daniel Lichtblau Feb 5 '13 at 15:54dStart = Min@data; bStart = Position[data, Max@data] // Flatten // Mean; cStart = Max[#] - Min[#] & @ Flatten[Position[data, Alternatives @@ Select[data, 2 (# - dStart ) >= (Max@data - dStart) &]]] /2; aStart = (Max@data - dStart) cStart;
$\endgroup$ – whuber Feb 5 '13 at 17:03