Tools

juobs.corr_obsFunction
corr_obs(cdata::CData; real::Bool=true, rw::Union{Array{Float64, 2}, Nothing}=nothing, L::Int64=1, info::Bool=false)

corr_obs(cdata::Array{CData, 1}; real::Bool=true, rw::Union{Array{Array{Float64, 2}, 1}, Nothing}=nothing, L::Int64=1, info::Bool=false)

Creates a Corr struct with the given CData struct cdata (read_mesons) for a single replica. An array 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)

#Single replica
data = read_mesons(path, "G5", "G5")
rw = read_ms1(path_rw)
corr_pp = corr_obs.(data)
corr_pp_r = corr_obs.(data, rw=rw)

#Single replica + Info
data = read_mesons(path, "G5", "G5")
rw = read_ms1(path_rw)
corr_pp, O = corr_obs(data[1], info=true)
corr_pp_r, WO, W = corr_obs(data[1], 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])
source
juobs.corr_symFunction
corr_sym(corrL::Corr, corrR::Corr, parity::Int64=1)

Computes the symmetrized correlator using the left correlador corrL and the right correlator corrR. The source position of corrR must be T - 1 - y0, where y0 is the source position of corrL.

pp_sym = corr_sym(ppL, ppR, +1)
a0p_sym = corr_sym(a0pL, a0pR, -1)
source
juobs.md_seaFunction
md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ow::uwreal, w::Union{uwreal, Nothing}=nothing, ws::ADerrors.wspace=ADerrors.wsg)

md_sea(a::uwreal, md::Vector{Matrix{Float64}}, ow::Array{uwreal}, w::Union{uwreal, Nothing}=nothing, ws::ADerrors.wspace=ADerrors.wsg)

Computes the derivative of an observable A with respect to the sea quark masses.

$\frac{d <A>}{dm(sea)} = \sum_i \frac{\partial <A>}{\partial <O_i>} \frac{d <O_i>}{d m(sea)}$

$\frac{d <O_i>}{dm(sea)} = <O_i> <\frac{\partial S}{\partial m}> - <O_i \frac{\partial S}{\partial m}>$

where $O_i$ are primary observables. The function returns $\frac{\partial <A>}{\partial <O_i>} \frac{d <O_i>}{d m(sea)}$, where the primary observable $O_i$ is specified as an input argument.

ow is a primary observable or a vector of primary observables that contains $<OW>$ ($<O>$ if reweighting is not applied) and w is a primary obserable that contains the reweighting factors $<W>$ (w=nothing if reweighting is not applied).

md is a vector that contains the derivative of the action $S$ with respect to the sea quark masses for each replica. md[irep][irw, icfg]

md_sea returns a tuple of uwreal observables $(dA/dm_l, dA/dm_s)|_{sea}$, where $m_l$ and $m_s$ are the light and strange quark masses.

#Single replica
data = read_mesons(path, "G5", "G5")
md = read_md(path_md)
rw = read_ms1(path_rw)

corr_pp, wpp, w = corr_obs.(data[1], rw=rw, info=true)
m = meff(corr_pp[1], plat)
m_mdl, m_mds = md_sea(m, [md], wpp, w, ADerrors.wsg)
m_shifted = m + 2 * dml * m_mdl + dms * m_mds

#Two replicas
data = read_mesons([path_r1, path_r2], "G5", "G5")
md1 = read_md(path_md1)
md2 = read_md(path_md2)

corr_pp, pp = corr_obs(data[1], info=true)
m = meff(corr_pp[1], plat)
m_mdl, m_mds = md_sea(m, [md1, md2], pp, ADerrors.wsg)
m_shifted = m + 2 * dml * m_mdl + dms * m_mds
source
juobs.md_valFunction
md_val(a::uwreal, obs::Corr, derm::Vector{Corr})

Computes the derivative of an observable A with respect to the valence quark masses.

$\frac{d <A>}{dm(val)} = \sum_i \frac{\partial <A>}{\partial <O_i>} \frac{d <O_i>}{d m(val)}$

$\frac{d <O_i>}{dm(val)} = <\frac{\partial O_i}{\partial m(val)}>$

where $O_i$ are primary observables

md is a vector that contains the derivative of the action $S$ with respect to the sea quark masses for each replica. md[irep][irw, icfg]

md_val returns a tuple of uwreal observables $(dA/dm_1, dA/dm_2)|_{val}$, where $m_1$ and $m_2$ are the correlator masses.

data = read_mesons(path, "G5", "G5", legacy=true)
data_d1 = read_mesons(path, "G5_d1", "G5_d1", legacy=true)
data_d2 = read_mesons(path, "G5_d2", "G5_d2", legacy=true)

rw = read_ms1(path_rw)

corr_pp = corr_obs.(data, rw=rw)
corr_pp_d1 = corr_obs.(data_d1, rw=rw)
corr_pp_d2 = corr_obs.(data_d2, rw=rw)
derm = [[corr_pp_d1[k], corr_pp_d2[k]] for k = 1:length(pp_d1)]

m = meff(corr_pp[1], plat)
m_md1, m_md2 = md_val(m, corr_pp[1], derm[1])
m_shifted = m + dm1 * m_md1 + dm2 * m_md2
source
juobs.lin_fitFunction
lin_fit(x::Vector{<:Real}, y::Vector{uwreal})

Computes a linear fit of uwreal data points y. This method return uwreal fit parameters and chisqexpected.

fitp, csqexp = lin_fit(phi2, m2)
m2_phys = fitp[1] + fitp[2] * phi2_phys
source
juobs.fit_routineFunction
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)

fit_routine(model::Function, xdata::Array{uwreal}, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing, covar::Bool=false)

Given a model function with a number param of parameters and an array of uwreal, this function fit ydata with the given model and print fit information The method return an array upar with the best fit parameters with their errors. The flag wpm is an optional array of Float64 of lenght 4. The first three paramenters specify the criteria to determine the summation windows:

  • vp[1]: The autocorrelation function is summed up to $t = round(vp[1])$.

  • vp[2]: The sumation window is determined using U. Wolff poposal with $S_\tau = wpm[2]$

  • vp[3]: The autocorrelation function $\Gamma(t)$ is summed up a point where its error $\delta\Gamma(t)$ is a factor vp[3] times larger than the signal.

An additional fourth parameter vp[4], tells ADerrors to add a tail to the error with $\tau_{exp} = wpm[4]$. Negative values of wpm[1:4] are ignored and only one component of wpm[1:3] needs to be positive. If the flag covaris set to true, fit_routine takes into account covariances between x and y for each data point.

@. model(x,p) = p[1] + p[2] * exp(-(p[3]-p[1])*x)
@. model2(x,p) = p[1] + p[2] * x[:, 1] + (p[3] + p[4] * x[:, 1]) * x[:, 2]
fit_routine(model, xdata, ydata, param=3)
fit_routine(model, xdata, ydata, param=3, covar=true)
source
juobs.bayesian_avFunction
bayesian_av(fun::Function, y::Array{uwreal}, tmin_array::Array{Int64}, tmax_array::Array{Int64}, k::Int64, pl::Bool, data::Bool; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)

bayesian_av(fun1::Function, fun2::Function, y::Array{uwreal}, tmin_array::Array{Int64}, tmax_array::Array{Int64}, k1::Int64, k2::Int64, pl::Bool, data::Bool; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)

bayesian_av(fun::Array{Function}, y::Array{uwreal}, tmin_array::Array{Int64}, tmax_array::Array{Int64}, k::Array{Int64}, pl::Bool, data::Bool; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)

Computes bayesian average of data. For a given fit function, it explores choices of fit intervals, assigning each of them a weight. The function saves the first fit parameter of your function, and then it does the weighted average of it and assigns a systematic. See https://arxiv.org/abs/2008.01069

The function takes as input the fit intervals to explore.

tmin_array is an array of integers with the lower bounds on the fit intervals to explore, ***ordered from lower to higher***.

tmax_array is an array of integers with the upper bounds on the fit intervals to explore, ***ordered from lower to higher***.

k is the number of parameters of the fit function to use.

You can also use as input two fit functions, and two values of k, one for each function. Then, for each fit interval choice, the function explores the two fit functions. This means that for each fit interval choice you get two results: one for the first fit funcction, and another for the second. You can also use a vector of functions and a vector of k (numer of parameters of each funtion) to apply the bayesian averaging method to multiple functions.

The method returns two objects: first, the weighted average as an uwreal object, with mean value and statistichal error. The second object returned is the systematic error coming from the fit interval variation. If data is true, then returns 4 objects: weighted average, systematic error, a vector with the results of the fit for each fit interval choice, and a vector with the weights associated to each fit.

@.fun(x,p) = p[1] * x ^0
k = 1
tmin_array = [10,11,12,13,14,15]
tmax_array = [80,81,82,83,84,85]
(average, systematics, data, weights) = bayesian_av(fun,x,tmin_array,tmax_array,k,pl=true,data=true)

@.fun1(x,p) = p[1] * x ^0
@.fun2(x,p) = p[1] + p[2] * exp( - p[3] * (x))
k1 = 1
k2 = 3
tmin_array = [10,11,12,13,14,15]
tmax_array = [80,81,82,83,84,85]
(average, systematics) = bayesian_av(fun1,fun2,x,tmin_array,tmax_array,k1,k2)

@.fun1(x,p) = p[1] * x ^0
@.fun2(x,p) = p[1] + p[2] * exp( - p[3] * (x))
k1 = 1
k2 = 3
tmin_array = [10,11,12,13,14,15]
tmax_array = [80,81,82,83,84,85]
(average, systematics) = bayesian_av([fun1,fun2],x,tmin_array,tmax_array,[k1,k2])
source