Computes bayesian average of data. For a given fit function, it explores choices of fit intervals, assigning each a weight. Then it does the weighted average 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.
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.
function bayesian_av(fun::Function,y::Array{uwreal},tmin_array::Array{Int64},tmax_array::Array{Int64},k::Int64;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}()
iftmax_array[end]>length(y)
error("Error: upper bound for the fits is bigger than last data point")