Commit 2bfbc0c6 authored by Javier's avatar Javier

minor bugs lin_fit + fit_routine

uwerr missing
dof not reading length
parent 9a0d2137
......@@ -127,7 +127,7 @@ function lin_fit(x::Vector{<:Real}, y::Vector{uwreal})
print("\n Fit parameter: ", i, ": ")
details(fitp[i])
end
println("Chisq / chiexp: ", chisq(par, y), " / ", csqexp, " (dof: ", x[end]-length(par),")")
println("Chisq / chiexp: ", chisq(par, y), " / ", csqexp, " (dof: ", length(x)-length(par),")")
return (fitp, csqexp)
end
......@@ -155,6 +155,7 @@ The method return an array upar with the best fit parameters with their errors.
fit_routine(model, ydata, param=3)
"""
function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing )
uwerr.(ydata)
yval = value.(ydata)
yer = err.(ydata)
chisq = gen_chisq(model, xdata, yer)
......@@ -172,7 +173,6 @@ function gen_chisq(f::Function, x::Array{<:Real}, err::Vector{Float64})
chisq(par, dat) = sum((dat .- f(x,par)).^2 ./err.^2)
return chisq
end
#TODO: add combined fits
#=
using LsqFit
@doc raw"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment