Commit 66634ada authored by ale's avatar ale

bug in pvalue

parent bdfb1f52
......@@ -1589,12 +1589,11 @@ Q = pvalue(chisq, chi2, value.(up), y, wpm; W = 1.0 ./ err.(y) .^ 2, nmc=10000)
```
"""
function juobs.pvalue(chisq::Function,
function pvalue(chisq::Function,
chi2::Float64,
xp::Vector{Float64},
data::Vector{uwreal};
wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing} = Dict{Int64,Vector{Float64}}(),
W::Vector{Float64} = Vector{Float64}(),
nmc::Int64 = 5000)
n = length(xp) # Number of fit parameters
......@@ -1618,8 +1617,7 @@ function juobs.pvalue(chisq::Function,
ForwardDiff.hessian!(hess, ccsq, xav, cfg)
if (m-n > 0)
if (length(W) == 0)
Ww = zeros(Float64, m)
W = zeros(Float64, m)
for i in 1:m
if (data[i].err == 0.0)
#isnothing(wpm) ? wuerr(data[i]) : uwerr(data[i], wpm)
......@@ -1628,10 +1626,8 @@ function juobs.pvalue(chisq::Function,
error("Zero error in fit data")
end
end
Ww[i] = 1.0 / data[i].err^2
W[i] = 1.0 / data[i].err^2
end
W = Ww
end
m = length(data)
n = size(hess, 1) - m
......@@ -1671,7 +1667,7 @@ function juobs.pvalue(chisq::Function,
return Q
end
function juobs.pvalue(chisq::Function,
function pvalue(chisq::Function,
chi2::Float64,
xp::Vector{Float64},
data::Vector{uwreal};
......
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