Commit 1cbf03a4 authored by Antonino D'Anna's avatar Antonino D'Anna

added verbose bool variable to fit_routine

parent 433cecee
...@@ -1095,7 +1095,7 @@ fit_routine(model, xdata, ydata, param=3, covar=true) ...@@ -1095,7 +1095,7 @@ fit_routine(model, xdata, ydata, param=3, covar=true)
``` ```
""" """
function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal}, param::Int64=3; info::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing, function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal}, param::Int64=3; info::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing,
inv_cov::Union{Matrix{Float64}, Nothing}=nothing) inv_cov::Union{Matrix{Float64}, Nothing}=nothing, verbose::Bool = true)
isnothing(wpm) ? uwerr.(ydata) : [uwerr(yaux, wpm) for yaux in ydata] isnothing(wpm) ? uwerr.(ydata) : [uwerr(yaux, wpm) for yaux in ydata]
...@@ -1125,26 +1125,30 @@ function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal} ...@@ -1125,26 +1125,30 @@ function fit_routine(model::Function, xdata::Array{<:Real}, ydata::Array{uwreal}
# println((fit.resid[i])^2) # println((fit.resid[i])^2)
# end # end
# println("\n") # println("\n")
if verbose
println("chi2 from fit residual = ", chi2_fit_res) println("chi2 from fit residual = ", chi2_fit_res)
println("chi2 from chi2 function = ", chisq(coef(fit), ydata)) println("chi2 from chi2 function = ", chisq(coef(fit), ydata))
end
#Info #Info
if info if info
for i = 1:length(upar) for i = 1:length(upar)
isnothing(wpm) ? uwerr(upar[i]) : uwerr(upar[i], wpm) isnothing(wpm) ? uwerr(upar[i]) : uwerr(upar[i], wpm)
if verbose
print("\n Fit parameter: ", i, ": ") print("\n Fit parameter: ", i, ": ")
details(upar[i]) details(upar[i])
end end
end end
end
#chis2_corrected = (length(yval) - param) * chisq(coef(fit), ydata) / chi_exp #chis2_corrected = (length(yval) - param) * chisq(coef(fit), ydata) / chi_exp
chis2_corrected = (length(yval) - param) * chi2_fit_res / chi_exp chis2_corrected = (length(yval) - param) * chi2_fit_res / chi_exp
if verbose
#println("Chisq / chiexp: ", chisq(coef(fit), ydata), " / ", chi_exp, " (dof: ", length(yval) - param,")") #println("Chisq / chiexp: ", chisq(coef(fit), ydata), " / ", chi_exp, " (dof: ", length(yval) - param,")")
println("Chisq / chiexp: ", chi2_fit_res, " / ", chi_exp, " (dof: ", length(yval) - param,")") println("Chisq / chiexp: ", chi2_fit_res, " / ", chi_exp, " (dof: ", length(yval) - param,")")
println("Chisq corrected: ", chis2_corrected) println("Chisq corrected: ", chis2_corrected)
println("Return: params, chi2, chi2exp") println("Return: params, chi2, chi2exp")
end
return upar, chi2_fit_res, chi_exp return upar, chi2_fit_res, chi_exp
end end
......
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