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.
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)
weight_model=Array{Float64,1}()
AIC=Array{Float64,1}()
chi2chi2exp=Array{Float64,1}()
p1=Array{uwreal,1}()
mods=Array{String,1}()
iftmax_array[end]>length(y)
error("Error: upper bound for the fits is bigger than last data point")
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}()
chi2chi2exp=Array{Float64,1}()
p1=Array{uwreal,1}()
mods=Array{String,1}()
iftmax_array[end]>length(y)
error("Error: upper bound for the fits is bigger than last data point")
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)
weight_model=Array{Float64,1}()
AIC=Array{Float64,1}()
chi2chi2exp=Array{Float64,1}()
p1=Array{uwreal,1}()
mods=Array{String,1}()
iftmax_array[end]>length(y)
error("Error: upper bound for the fits is bigger than last data point")