Interesting package. Like the multi-components parts.Will definitely test it out.
Just started testing it, already like it for its simplicity of use(very close to python lmfit, which I am used to).
Would you know if it is possible to pass arguments to the CMPFIT minimizer ? (such as xtol, maximum iterations, etc…) ?
Yes:
mzer = GFit.cmpfit()
mzer.config.xtol = 1.e-6
mzer.config.maxfev = 0
bestfit = fit!(model, data, minimizer=mzer)
See here for the list of options (section CONFIGURING MPFIT()
).
This looks like a great project, I’ll try it out next time I do fitting in julia.
FWIW I’d like to share my own attempt to mimic lmfit, you can get the full code at this gist: minimal version of lmfit in julia · GitHub
Since it was just for my own quick project I tried to make it as easy to use as possible to get my fit done. I like having the ability to easily create a model from a function and have all the params names after the function arguments. I also like in lmfit how you can use default argument for functions and the model learns about both the parameter and the default value, though I never got that working.
Here is an example usage:
julia> x = 1:100; ydata = x.^2.5;
julia> f(x,a,b) = x.^a .+ b;
julia> model, params = model_and_params(f)
(Model("f", f, 2), Param[Param("a", val=NaN, min=-Inf, max=Inf, vary=true, unc=NA), Param("b", val=NaN, min=-Inf, max=Inf, vary=true, unc=NA)])
julia> params.a(val=3, min=1, max=4)
julia> params.b(val=.1, vary=false) # lets force the fit to be wrong, since our models are usually somewhat wrong on real data
julia> result=fit(model, params; x=x, y=ydata);
julia> result.params
2-element Array{Param,1}:
Param("a", val=2.4999996296745217, min=1.0, max=4.0, vary=true, unc=3.987469111135028e-8)
Param("b", val=0.1, min=-Inf, max=Inf, vary=false, unc=NA)
@gcalderone, the GFit.jl
is a very nice package. Is it possible to combine several components that share (or have analytical relation) of a certain parameter? In the spectroscopy (characteristic X-rays) I’m fitting several overlapping gaussian peaks and I know apriori that all lines share the same width. So, doing fitting manually (e.g. using LsqFit.jl) I have a single model function that consists of several Gaussians, but shares a single \sigma .
Is it possible to achieve this somehow also with GFit.jl?
Dear all, the development took much longer than expected…
However, the package is now released, although with a different name: GModelFit.jl (see here…
Comments welcome!