Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
3ed50894
Commit
3ed50894
authored
6 years ago
by
Colm Talbot
Browse files
Options
Downloads
Patches
Plain Diff
make Student t likelihood more transparent
parent
8be9b27b
No related branches found
No related tags found
1 merge request
!192
Update likelihoods
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tupak/core/likelihood.py
+19
-13
19 additions, 13 deletions
tupak/core/likelihood.py
with
19 additions
and
13 deletions
tupak/core/likelihood.py
+
19
−
13
View file @
3ed50894
...
...
@@ -319,32 +319,38 @@ class StudentTLikelihood(Analytical1DLikelihood):
self
.
parameters
[
'
nu
'
]
=
None
def
log_likelihood
(
self
):
if
self
.
__get_nu
()
<=
0.
:
raise
ValueError
(
"
Number of degrees of freedom for Student
'
s t-likelihood must be positive
"
)
return
self
.
__summed_log_likelihood
(
self
.
__get_nu
())
if
self
.
nu
<=
0.
:
raise
ValueError
(
"
Number of degrees of freedom for Student
'
s
"
"
t-likelihood must be positive
"
)
nu
=
self
.
nu
log_l
=
\
np
.
sum
(
-
(
nu
+
1
)
*
np
.
log1p
(
self
.
lam
*
self
.
residual
**
2
/
nu
)
/
2
+
np
.
log
(
self
.
lam
/
(
nu
*
np
.
pi
))
/
2
+
gammaln
((
nu
+
1
)
/
2
)
-
gammaln
(
nu
/
2
))
return
log_l
def
__repr__
(
self
):
return
self
.
__class__
.
__name__
+
'
(x={}, y={}, func={}, nu={}, sigma={})
'
\
.
format
(
self
.
x
,
self
.
y
,
self
.
func
.
__name__
,
self
.
nu
,
self
.
sigma
)
base_string
=
'
(x={}, y={}, func={}, nu={}, sigma={})
'
return
self
.
__class__
.
__name__
+
base_string
.
format
(
self
.
x
,
self
.
y
,
self
.
func
.
__name__
,
self
.
nu
,
self
.
sigma
)
@property
def
lam
(
self
):
"""
Converts
'
scale
'
to
'
precision
'
"""
return
1.
/
self
.
sigma
**
2
def
__get_nu
(
self
):
@property
def
nu
(
self
):
"""
This checks if nu or sigma have been set in parameters. If so, those
values will be used. Otherwise, the attribute nu is used. The logic is
that if nu is not in parameters the attribute is used which was
given at init (i.e. the known nu as a float).
"""
return
self
.
parameters
.
get
(
'
nu
'
,
self
.
nu
)
return
self
.
parameters
.
get
(
'
nu
'
,
self
.
_
nu
)
def
__summed_log_likelihood
(
self
,
nu
):
return
(
self
.
n
*
(
gammaln
((
nu
+
1.0
)
/
2.0
)
+
.
5
*
np
.
log
(
self
.
lam
/
(
nu
*
np
.
pi
))
-
gammaln
(
nu
/
2.0
))
-
(
nu
+
1.0
)
/
2.0
*
np
.
sum
(
np
.
log1p
(
self
.
lam
*
self
.
residual
**
2
/
nu
)))
@nu.setter
def
nu
(
self
,
nu
):
self
.
_nu
=
nu
class
JointLikelihood
(
Likelihood
):
...
...
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