What am I doing wrong here?
using LsqFit
polynom(x,p) = p[1].+p[2].*x
curve_fit(polynom, 1:100,polynom(1:100,[10 10]),[0.5 0.5])
And I get this error
ERROR: MethodError: no method matching levenberg_marquardt(::NLSolversBase.OnceDifferentiable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Matrix{Float64}, Matrix{Float64}}, ::Matrix{Float64})
You might have used a 2d row vector where a 1d column vector was required.
Note the difference between 1d column vector [1,2,3] and 2d row vector [1 2 3].
You can convert to a column vector with the vec() function.
Closest candidates are:
levenberg_marquardt(::NLSolversBase.OnceDifferentiable, ::AbstractVector{T}; x_tol, g_tol, maxIter, lambda, tau, lambda_increase, lambda_decrease, min_step_quality, good_step_quality, show_trace, lower, upper, avv!) where T at C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\levenberg_marquardt.jl:34
Stacktrace:
[1] lmfit(R::NLSolversBase.OnceDifferentiable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Matrix{Float64}, Matrix{Float64}}, p0::Matrix{Float64}, wt::Vector{Int64}; autodiff::Symbol, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ LsqFit C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:68
[2] lmfit(R::NLSolversBase.OnceDifferentiable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Matrix{Float64}, Matrix{Float64}}, p0::Matrix{Float64}, wt::Vector{Int64})
@ LsqFit C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:68
[3] lmfit(f::LsqFit.var"#18#20"{typeof(polynom), UnitRange{Int64}, StepRangeLen{Int64, Int64, Int64, Int64}}, p0::Matrix{Float64}, wt::Vector{Int64}; autodiff::Symbol, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ LsqFit C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:64
[4] lmfit(f::Function, p0::Matrix{Float64}, wt::Vector{Int64})
@ LsqFit C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:61
[5] curve_fit(model::typeof(polynom), xdata::UnitRange{Int64}, ydata::StepRangeLen{Int64, Int64, Int64, Int64}, p0::Matrix{Float64}; inplace::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ LsqFit C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:115
[6] curve_fit(model::Function, xdata::UnitRange{Int64}, ydata::StepRangeLen{Int64, Int64, Int64, Int64}, p0::Matrix{Float64})
@ LsqFit C:\Users\torfi\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:106
[7] top-level scope
@ REPL[3]:1
Shouldn’t this just work? To use a function to fit to the output of that function? I am so confused.