I have a vector of data points:
data = 10 Sin[#/10] + RandomVariate@NormalDistribution[] & /@
Range[200];
And I have model that provides the complete data vector as value
matrix = Table[i (Sin[j/10]), {i, 20}, {j, 200}];
weights[a_] := Table[PDF[NormalDistribution[a, 1], i], {i, Range@20}];
model[a_] := weights[a].matrix;
model[10]
is a good approximation of data.
They way I currently determine the fit parameters is by using FindMinimum
and explicitly minimize the fit penalty:
FindMinimum[
Total[(data - model[a])^2],
{{a, 10}}
]
This works nice. But the evaluation of fit statistics like error volumes is very tedious because the underlying matrix and the model function is rather complex. When fitting with NonlinearModelFit
instead, a lot of those statistics are readily available. But I have struggled to adapt it accordingly:
Something like
NonlinearModelFit[
data,
model[a],
{{a, 1}},
var
]
Unfortunately, there are problems. Can it be adapted? I dont actually need any variables to fit the expressions.
Kind regards
Comments
Post a Comment