function check_corr_der(obs::Corr,derm::Vector{Corr};new_version::Bool=false)
g1=Vector{String}(undef,0)
...
...
@@ -150,21 +160,24 @@ corr_pp = corr_obs.(data)
corr_pp_r = corr_obs.(data, rw=[rw1, rw2])
```
"""
function corr_obs(cdata::CData;real::Bool=true,rw::Union{Array{Float64,2},Nothing}=nothing,L::Int64=1,info::Bool=false,flag_strange::Bool=false)
function corr_obs(cdata::CData;real::Bool=true,rw::Union{Array{Float64,2},Nothing}=nothing,L::Int64=1,info::Bool=false,idm::Union{Vector{Int64},Nothing}=nothing,nms::Int64=Int64(maximum(cdata.vcfg)),flag_strange::Bool=false)
@@ -178,11 +191,22 @@ function corr_obs(cdata::CData; real::Bool=true, rw::Union{Array{Float64, 2}, No
end
#function corr_obs for R != 1
#TODO: vcfg with gaps
function corr_obs(cdata::Array{CData,1};real::Bool=true,rw::Union{Array{Array{Float64,2},1},Nothing}=nothing,L::Int64=1,info::Bool=false,flag_strange::Bool=false)
function corr_obs(cdata::Array{CData,1};real::Bool=true,rw::Union{Array{Array{Float64,2},1},Nothing}=nothing,L::Int64=1,info::Bool=false,idm::Union{Vector{Int64},Nothing}=nothing,nms::Union{Int64,Nothing}=nothing,flag_strange::Bool=false)
Creates a `Corr` struct for Truncated Solver Method (TSM) with the given `CData` structs `cdata_sl` and `cdata_ex` for a single replica.
Two arrays of `CData` can be passed as argument for multiple replicas.
The flag `real` select the real or imaginary part of the correlator.
If `rw` is specified, the method applies reweighting. `rw` is passed as a matrix of Float64 (`read_ms1`)
The correlator can be normalized with the volume factor if `L` is fixed.
The flag `info` provides extra output that contains information about the primary observables. The function returns the primary observables ``<WO>`` and ``<W>``
(it returns the observable <O> if rw=nothing)
The flags `idm_sl`, `idm_corr` and `nms` can be used if the observable is not measure in every configuration. In particular:
`idm_sl::Vector{Int64}` If given, label the configurations where the sloppy observables is measured. Not required if sloppy is full statistics.
`idm_corr::Vector{Int64}` If given, label the configurations where the correction observables is measured. Not required if correction is full statistics.
`nms::Int64` Total number of measurements in the ensembles. By default, nms=maximum(cdata_sl.vcfg) it is assumed that the sloppy observable is full statistics, while the exact observable is not.
Typically, only `idm_corr` has to be passed, if the exact observable is not full statistics.
By playing with these three flags you ensure that the Gamma method is still working even if the configurations between sloppy and correction do not match.
corr_pp, O = corr_obs_TSM(data_sloppy, data_correction, info=true)
corr_pp_r, WO, W = corr_obs(data_sloppy, data_correction,, rw=rw, info=true)
#Two replicas
data = read_mesons([path_r1, path_r2], "G5", "G5")
rw1 = read_ms1(path_rw1)
rw2 = read_ms1(path_rw2)
corr_pp = corr_obs.(data)
corr_pp_r = corr_obs.(data, rw=[rw1, rw2])
```
"""
function corr_obs_TSM(cdata_sl::CData,cdata_corr::CData;real::Bool=true,rw::Union{Array{Float64,2},Nothing}=nothing,L::Int64=1,info::Bool=false,idm_sl::Union{Vector{Int64},Nothing}=nothing,idm_corr::Union{Vector{Int64},Nothing}=nothing,nms::Union{Int64,Nothing}=nothing)
# cdata1 is sloppy, cdata2 is correction
ifcdata_sl.id!=cdata_corr.id
error("Error: cdata_sl id != cdata_corr id")
end
ifcdata1.header!=cdata2.header# Base.:(==) and Base.:(!=) are redifined in juobs_types.jl
error("Error: cdata1 header != cdata2 header")
ifcdata_sl.header!=cdata_corr.header# Base.:(==) and Base.:(!=) are redifined in juobs_types.jl
function corr_obs_TSM(cdata1::Array{CData,1},cdata2::Array{CData,1};real::Bool=true,rw::Union{Array{Array{Float64,2},1},Nothing}=nothing,L::Int64=1,info::Bool=false)
function corr_obs_TSM(cdata1::Array{CData,1},cdata2::Array{CData,1};real::Bool=true,rw::Union{Array{Array{Float64,2},1},Nothing}=nothing,L::Int64=1,info::Bool=false,idm_sl::Union{Vector{Int64},Nothing}=nothing,idm_corr::Union{Vector{Int64},Nothing}=nothing,nms::Union{Int64,Nothing}=nothing)
function bayesian_av(fun::Function,y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k::Int64,pl::Bool=false,data::Bool=false;wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing)
function bayesian_av(fun::Function,y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k::Int64;pl::Bool=false,data::Bool=false,
function bayesian_av(fun1::Function,fun2::Function,y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k1::Int64,k2::Int64,pl::Bool=false,data::Bool=false;wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing)
function bayesian_av(fun1::Function,fun2::Function,y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k1::Int64,k2::Int64;pl::Bool=false,data::Bool=false,wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing)
weight_model=Array{Float64,1}()
AIC=Array{Float64,1}()
...
...
@@ -720,7 +899,7 @@ function bayesian_av(fun1::Function, fun2::Function, y::Array{uwreal}, tmin_arra
push!(AIC,chi2+2*k2+2*Ncut)
push!(chi2chi2exp,chi2/dof(fit))
push!(p1,up[1])
println(up[end])
push!(mods,string("[",INDEX+1,",",j,"]"))
catche
...
...
@@ -768,20 +947,23 @@ function bayesian_av(fun1::Function, fun2::Function, y::Array{uwreal}, tmin_arra
end
function bayesian_av(fun::Array{Function},y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k::Array{Int64},pl::Bool=false,data::Bool=false;wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing)
function bayesian_av(fun::Array{Function},y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k::Array{Int64};pl::Bool=false,
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,correlated_fit::Bool=false)
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::Vector{Function},xdata::Vector{Array{Float64,N}}whereN,ydata::Vector{Array{uwreal,N}}whereN,param::Int64;wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing)
function fit_routine(model::Vector{Function},xdata::Vector{Array{Float64,N}}whereN,ydata::Vector{Array{uwreal,N}}whereN,param::Int64;wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing,
correlated_fit::Bool=false)
if!(length(model)==length(xdata)==length(ydata))
error("Dimension mismatch")
end
...
...
@@ -987,7 +1234,11 @@ function fit_routine(model::Vector{Function}, xdata::Vector{Array{Float64, N}} w
ifisnothing(wpm)
uwerr.(ydata[i])
else
[uwerr(yaux,wpm)foryauxinydata[i]]
# println(yaux for yaux in ydata[i])
foryauxinydata[i]
[uwerr(yaux[k],wpm)forkin1:length(yaux)]
end
# [[uwerr(yaux[k], wpm) for k in eachindex(yaux)] for yaux in ydata[i]]
end
e[i]=err.(ydata[i])
...
...
@@ -998,20 +1249,48 @@ function fit_routine(model::Vector{Function}, xdata::Vector{Array{Float64, N}} w
@@ -1094,7 +1373,10 @@ function fit_routine(model::Function, xdata::Array{uwreal}, ydata::Array{uwreal}
end
function global_fit_routine(models::Vector{Function},xdata::Vector{Array{Float64,1}},ydata::Vector{Array{uwreal,1}},n_par::Int64;guess_param::Vector{Float64}=fill(0.5,n_par),log::Bool=true,wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}},Nothing}=nothing)
function global_fit_routine(models::Vector{Function},xdata::Vector{Array{Float64,1}},ydata::Vector{Array{uwreal,1}},n_par::Int64;guess_param::Vector{Float64}=fill(0.5,n_par),log::Bool=true,