Maybe this question is kind of trivial, but since I’m a Julia newbie I hoped to find some help and/or advice here.
I would like to fit different functions to some data. They only differ by one parameter
k. The following code does not run. It is rather a “statement of intent” to explain what my goal is:
function model(x, p, k) sum([p[i]*(x.^i/factorial(i)) for i in 1:k]) end for i in 1:10 fit = curve_fit(model(.,.,i), x, y) ... some more code ... end
It worked to a point, where different …things where generate ( of type
var"#574#576") These objects can be evaluated and yield some value if provided with arguments. But the
curve_fit function does not like this type of object. I tried to use something like:
function m(k) return :((x,p) -> sum([p[i]*(x.^i./factorial(i)) for i in 1:k])) end for l in 1:10 curve_fit(eval(m(l)), x, y) ... some code ... end
I’d appreciate if someone could help me with this.