Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PeakOTron
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UHHDetLab
SiPM
PeakOTron
Commits
e43c2a67
Commit
e43c2a67
authored
2 years ago
by
Jack Christopher Hutchinson Rolph
Browse files
Options
Downloads
Patches
Plain Diff
Delete LossFunctions.py
parent
38abbbcd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LossFunctions.py
+0
-100
0 additions, 100 deletions
LossFunctions.py
with
0 additions
and
100 deletions
LossFunctions.py
deleted
100644 → 0
+
0
−
100
View file @
38abbbcd
import
numpy
as
np
from
scipy.interpolate
import
interp1d
from
iminuit.util
import
describe
from
Model
import
epsilon
from
HelperFunctions
import
FakeFuncCode
import
matplotlib.pyplot
as
plt
class
BinnedLH
:
def
__init__
(
self
,
f
,
bcs
,
counts
,
bw
):
self
.
f
=
f
self
.
x
=
bcs
self
.
dx
=
bw
self
.
counts
=
counts
self
.
N
=
np
.
sum
(
counts
)
self
.
last_arg
=
None
self
.
func_code
=
FakeFuncCode
(
f
,
dock
=
True
)
self
.
n_calls
=
0
self
.
eps
=
epsilon
()
def
__call__
(
self
,
*
arg
):
self
.
last_arg
=
arg
y_hat
=
self
.
f
(
self
.
x
,
*
arg
)
y_hat
=
np
.
nan_to_num
(
y_hat
,
nan
=
self
.
eps
,
posinf
=
self
.
eps
,
neginf
=
self
.
eps
)
y_hat
=
np
.
where
(
y_hat
<
self
.
eps
,
self
.
eps
,
y_hat
)
E
=
y_hat
*
self
.
N
*
self
.
dx
h
=
self
.
counts
mask
=
(
h
>
0
)
E
=
E
[
mask
]
h
=
h
[
mask
]
nlogL
=
-
np
.
sum
(
h
*
(
np
.
log
(
E
)
-
np
.
log
(
h
))
+
(
h
-
E
))
self
.
n_calls
+=
1
return
nlogL
class
Chi2Regression
:
def
__init__
(
self
,
f
,
x
,
y
,
y_err
,
epsilon
=
1.35
):
self
.
f
=
f
self
.
x
=
x
self
.
y
=
y
self
.
y_err
=
y_err
self
.
eps
=
np
.
finfo
(
np
.
float64
).
eps
*
10
self
.
y_err
[
self
.
y_err
<
self
.
eps
]
=
self
.
eps
self
.
last_arg
=
None
self
.
func_code
=
FakeFuncCode
(
f
,
dock
=
True
)
self
.
ndof
=
len
(
self
.
y
)
-
(
self
.
func_code
.
co_argcount
-
1
)
def
__call__
(
self
,
*
arg
):
self
.
last_arg
=
arg
loss
=
((
self
.
f
(
self
.
x
,
*
arg
)
-
self
.
y
)
/
(
self
.
y_err
))
**
2
return
np
.
sum
(
loss
)
class
HuberRegression
:
def
__init__
(
self
,
f
,
x
,
y
,
y_err
,
delta
=
1.345
):
self
.
f
=
f
self
.
x
=
x
self
.
y
=
y
self
.
y_err
=
y_err
self
.
delta
=
delta
self
.
eps
=
np
.
finfo
(
np
.
float64
).
eps
*
10
self
.
y_err
[
self
.
y_err
<
self
.
eps
]
=
self
.
eps
self
.
last_arg
=
None
self
.
func_code
=
FakeFuncCode
(
f
,
dock
=
True
)
self
.
ndof
=
len
(
self
.
y
)
-
(
self
.
func_code
.
co_argcount
-
1
)
def
__call__
(
self
,
*
arg
):
self
.
last_arg
=
arg
a
=
abs
((
self
.
y
-
self
.
f
(
self
.
x
,
*
arg
))
/
self
.
y_err
)
cond_flag
=
(
a
>
self
.
delta
)
loss
=
np
.
sum
((
~
cond_flag
)
*
(
0.5
*
a
**
2
)
-
(
cond_flag
)
*
self
.
delta
*
(
0.5
*
self
.
delta
-
a
),
-
1
)
return
np
.
sum
(
loss
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment