Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
juobs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier Ugarrio
juobs
Commits
a2f4bcfc
Commit
a2f4bcfc
authored
Jan 06, 2026
by
Antonino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixes in fit routine
parent
5f3ab2cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
960 additions
and
965 deletions
+960
-965
src/juobs_fit.jl
src/juobs_fit.jl
+38
-38
src/juobs_linalg.jl
src/juobs_linalg.jl
+922
-927
No files found.
src/juobs_fit.jl
View file @
a2f4bcfc
"""
plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, [W::VecOrMat{Float64},] wpm::Union{Dict{Int64},Vector{Float{64}},Dict{String,Vector{Float{64}},Nothing}=nothing} )
...
...
@@ -159,7 +158,7 @@ function fit_routine(model::Function,
[
uwerr
(
y
,
wpm
)
for
y
in
ydata
]
if
length
(
W
)
==
0
if
corr
C
=
length
(
C
)
==
0
?
GammaMethod
.
cov_AD
(
ydata
,
wpm
)
:
C
C
=
length
(
C
)
==
0
?
GammaMethod
.
cov_AD
(
ydata
)
:
C
W
=
LinearAlgebra
.
pinv
(
C
);
W
=
(
W
'
+
W
)
*
0.5
else
...
...
@@ -282,36 +281,36 @@ It returns a `NamedTuple` with names:
- `:chiexp`: chisquare expected
- `:pval`: pvalue
"""
function
fit_routine
s
(
models
::
AbstractArray
{
Function
},
function
fit_routine
(
models
::
AbstractArray
{
Function
},
xdata
::
AbstractArray
{
<:
AbstractArray
},
ydata
::
AbstractArray
{
<:
AbstractArray
{
ADerrors
.
uwreal
}},
npar
::
Int64
;
W
::
AbstractArray
=
Float64
[],
C
::
AbstractArray
=
Float64
[],
W
=
Float64
[],
C
=
Float64
[],
wpm
::
AbstractDict
=
Dict
{
Int64
,
Vector
{
Float64
}}(),
corr
::
Bool
=
true
,
guess
::
AbstractArray
=
fill
(
0.5
,
npar
),
logfile
=
nothing
,
)
Nmodel
=
length
(
models
)
ndata
=
length
.
(
xdata
)
Ntotal
=
sum
(
ndata
);
if
Nmodel
!=
length
(
xdata
)
!=
length
(
ydata
)
error
(
"[juobs] Error: you need the same number of model, xdata and ydata"
)
end
if
!
(
length
(
W
)
==
0
||
length
(
W
)
==
Nmodel
)
error
(
"[juobs] Error: You need to pass a W matrix for model or none"
)
if
!
(
length
(
W
)
==
0
||
length
(
W
)
==
Nmodel
||
length
(
W
)
==
Ntotal
^
2
)
error
(
"[juobs] Error: You need to pass a W matrix for model
, for all the data
or none"
)
end
if
!
(
length
(
C
)
==
0
||
length
(
C
)
==
Nmodel
)
error
(
"[juobs] Error: You need to pass a C matrix for model or none"
)
if
!
(
length
(
C
)
==
0
||
length
(
C
)
==
Nmodel
||
length
(
C
)
==
Ntotal
^
2
)
error
(
"[juobs] Error: You need to pass a C matrix for model
, for all the data
or none"
)
end
ndata
=
length
.
(
xdata
)
if
!
all
(
length
.
(
ydata
)
.==
ndata
)
error
(
"[juobs] Error: Mismatch in xdata and ydata. Make sure that the data corresponds"
)
end
Ntotal
=
sum
(
ndata
);
X
=
vcat
(
xdata
...
)
Y
=
vcat
(
ydata
...
)
function
make_matrix
(
M
)
function
make_matrix
(
M
::
Vector
{
<:
AbstractMatrix
}
)
aux
=
zeros
(
Ntotal
,
Ntotal
)
ie
=
0
for
m
in
1
:
Nmodel
...
...
@@ -321,6 +320,7 @@ function fit_routines(models::AbstractArray{Function},
end
return
aux
end
make_matrix
(
M
::
T
where
{
T
<:
AbstractMatrix
})
=
M
WW
=
length
(
W
)
==
0
?
W
:
make_matrix
(
W
);
CC
=
length
(
C
)
==
0
?
C
:
make_matrix
(
C
);
...
...
src/juobs_linalg.jl
View file @
a2f4bcfc
#=
using ForwardDiff, LinearAlgebra
for op in (:eigvals, :eigvecs)
@eval function LinearAlgebra.$op(a::Matrix{uwreal})
@eval function LinearAlgebra.$op(a::Matrix{uwreal})
function fvec(x::Matrix)
return LinearAlgebra.$op(x)
end
return fvec(value.(a))
#return uwreal(LinearAlgebra.$op(a.mean), a.prop, ForwardDiff.derivative($op, a.mean)*a.der)
end
function fvec(x::Matrix)
return LinearAlgebra.$op(x)
end
return fvec(value.(a))
#return uwreal(LinearAlgebra.$op(a.mean), a.prop, ForwardDiff.derivative($op, a.mean)*a.der)
end
end
=#
...
...
@@ -893,14 +893,9 @@ Return the square absolute value.
Previously this function returned the absolute value of `uw`, not the square absolute value.
The function was changed to make it consistent with `Base.abs2()` in Julia.
When used, a warning is printed to informe of this change future users, feel free to remove the warning
from your branch!
"""
function
Base
.
abs2
(
uw
::
uwreal
)
@warn
"This function was updated by Antonino to make it consisted with the Julia version of it.
Check the documentation for info and then feel free to comment out this warning in your branch"
return
uw
^
2
end
Base
.
abs2
(
uw
::
uwreal
)
=
uw
^
2
"""
Base.abs(uw::uwreal)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment