Commit c8556db3 authored by Antonino D'Anna's avatar Antonino D'Anna

Replaced GammaMethod.cov_AD with ADerrors.cov_sym

parent 68e25eac
......@@ -88,7 +88,7 @@ function fit_routine(model::Function,
[uwerr(y, wpm) for y in ydata]
if length(W) ==0
if corr
C = length(C) ==0 ? GammaMethod.cov_AD(ydata) : C
C = length(C) ==0 ? ADerrors.cov_sym(ydata) : C
W = LinearAlgebra.pinv(C);
W = (W'+W)*0.5
else
......@@ -102,11 +102,14 @@ function fit_routine(model::Function,
chi2 = sum(fit.resid.^2)
par = fit_error(chisq,LsqFit.coef(fit),ydata,wpm,W,false)
# if the fit is correlated we have already C, no need to recompute it.
chiexp,pval = if length(C) !=0
GammaMethod.chiexp(chisq,LsqFit.coef(fit),value.(ydata),C,W),pvalue(chisq,chi2,LsqFit.coef(fit),ydata,W,C=C)
else
ADerrors.chiexp(chisq,LsqFit.coef(fit),ydata,wpm,W=W),pvalue(chisq,chi2,LsqFit.coef(fit),ydata,W,wpm=wpm)
end
chiexp = ADerrors.chiexp(chisq,
LsqFit.coef(fit),
ydata,
wpm,
C=length(C)==0 ? nothing : C,
W=W)
pval = pvalue(chisq,chi2,LsqFit.coef(fit),ydata,W,wpm=wpm,C=C)
compute_error_for_logging(logfile,par);
println(logfile, "fit_routine output:")
......
......@@ -35,7 +35,7 @@ end
W::Union{Vector{Float64},Array{Float64,2}} = Vector{Float64}();
wpm = Dict{Int64,Vector{Float64}}()
nmc::Int64 = 5000,
C::AbstractMatrix{Float64} = GammaMethod.cov_AD(data,wpm))
C::AbstractMatrix{Float64} = Matrix{Float64}(undef,0,0))
Computes the p-value of a previously done fit, using as input the `\chi^2` observed from the fit, the fit parameters and the fitted data.
The p-value for a given `\chi^2` is the probability of, given the data you have, finding such a `\chi^2` or worse from a fit, and still
......@@ -67,7 +67,7 @@ function pvalue(chisq::Function,
W::AbstractVector{Float64}=Vector{Float64}();
wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing} = Dict{Int64,Vector{Float64}}(),
nmc::Int64 = 5000,
C::AbstractMatrix{Float64} = ADerrors.cov(data,wpm))
C::AbstractMatrix{Float64} = Matrix{Float64}(undef,0,0))
n = length(xp) # Number of fit parameters
m = length(data) # Number of data
......@@ -128,6 +128,8 @@ function pvalue(chisq::Function,
_Px
end
length(C)!=0 || (C=ADerrors.cov_sym(data))
nu = let
aux = sqrt(C)
aux2 = similar(aux)
......
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