I am trying to extract fitting parameters, but I am unable to understand the error, it looks like dimensions are same. Both En and abs are row vector of size 601.
using LsqFit, DataFrames,DelimitedFiles, QuadGK
α(E,p) = ( p[1].*sqrt(p[2])./(E.*(2π) )).*(sum(m-> (2*p[2]/(m^3))*(1/p[4])*exp(-((E .- (p[3] - p[2]/(m^2)))^2)/(2*(p[4]^2))),1:1000 ) .+ (1/p[5]).*quadgk(x-> exp.(-(x .- E).^2/(2*p[5].^2))./(1 .- exp.(-2π*sqrt(p[2]./(x .- p[3]))) ),p[3],Inf,rtol=1e-3 ) )
p0=[1e+6,0.08,5.1,0.2,0.2]
fit=curve_fit(α,En,abs,p0)
DimensionMismatch("A has dimensions (1,601) but B has dimensions (1,601)")
Stacktrace:
[1] gemm_wrapper!(C::Matrix{Float64}, tA::Char, tB::Char, A::Matrix{Float64}, B::Matrix{Float64}, _add::LinearAlgebra.MulAddMul{true, true, Bool, Bool})
@ LinearAlgebra C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\matmul.jl:643
[2] mul!
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\matmul.jl:169 [inlined]
[3] mul!
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\matmul.jl:275 [inlined]
[4] *
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\matmul.jl:160 [inlined]
[5] power_by_squaring(x_::Matrix{Float64}, p::Int64)
@ Base .\intfuncs.jl:262
[6] ^
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\dense.jl:442 [inlined]
[7] macro expansion
@ .\none:0 [inlined]
[8] literal_pow
@ .\none:0 [inlined]
[9] (::var"#11#13"{LinearAlgebra.Transpose{Float64, Vector{Float64}}, Vector{Float64}})(m::Int64)
@ Main .\In[20]:1
[10] mapreduce_impl(f::var"#11#13"{LinearAlgebra.Transpose{Float64, Vector{Float64}}, Vector{Float64}}, op::typeof(Base.add_sum), A::UnitRange{Int64}, ifirst::Int64, ilast::Int64, blksize::Int64)
@ Base .\reduce.jl:242
[11] mapreduce_impl
@ .\reduce.jl:257 [inlined]
[12] _mapreduce(f::var"#11#13"{LinearAlgebra.Transpose{Float64, Vector{Float64}}, Vector{Float64}}, op::typeof(Base.add_sum), #unused#::IndexLinear, A::UnitRange{Int64})
@ Base .\reduce.jl:415
[13] _mapreduce_dim
@ .\reducedim.jl:318 [inlined]
[14] #mapreduce#672
@ .\reducedim.jl:310 [inlined]
[15] mapreduce
@ .\reducedim.jl:310 [inlined]
[16] #_sum#682
@ .\reducedim.jl:878 [inlined]
[17] _sum
@ .\reducedim.jl:878 [inlined]
[18] #sum#680
@ .\reducedim.jl:874 [inlined]
[19] sum
@ .\reducedim.jl:874 [inlined]
[20] α(E::LinearAlgebra.Transpose{Float64, Vector{Float64}}, p::Vector{Float64})
@ Main .\In[20]:1
[21] #18
@ C:\Users\usmaa\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:114 [inlined]
[22] lmfit(f::LsqFit.var"#18#20"{typeof(α), LinearAlgebra.Transpose{Float64, Vector{Float64}}, Vector{Float64}}, p0::Vector{Float64}, wt::Vector{Float64}; autodiff::Symbol, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ LsqFit C:\Users\usmaa\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:61
[23] lmfit
@ C:\Users\usmaa\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:61 [inlined]
[24] curve_fit(model::typeof(α), xdata::LinearAlgebra.Transpose{Float64, Vector{Float64}}, ydata::Vector{Float64}, p0::Vector{Float64}; inplace::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ LsqFit C:\Users\usmaa\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:115
[25] curve_fit(model::Function, xdata::LinearAlgebra.Transpose{Float64, Vector{Float64}}, ydata::Vector{Float64}, p0::Vector{Float64})
@ LsqFit C:\Users\usmaa\.julia\packages\LsqFit\hgZQe\src\curve_fit.jl:106
[26] top-level scope
@ In[20]:3
[27] eval
@ .\boot.jl:360 [inlined]
[28] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1116