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
38f9b94f
Commit
38f9b94f
authored
6 years ago
by
Colm Talbot
Browse files
Options
Downloads
Patches
Plain Diff
rationalise GaussianLikelihood
parent
69311d09
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!192
Update likelihoods
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tupak/core/likelihood.py
+12
-6
12 additions, 6 deletions
tupak/core/likelihood.py
with
12 additions
and
6 deletions
tupak/core/likelihood.py
+
12
−
6
View file @
38f9b94f
...
...
@@ -158,20 +158,26 @@ class GaussianLikelihood(Analytical1DLikelihood):
.
format
(
self
.
x
,
self
.
y
,
self
.
func
.
__name__
,
self
.
sigma
)
def
log_likelihood
(
self
):
return
self
.
__summed_log_likelihood
(
sigma
=
self
.
__get_sigma
())
log_l
=
np
.
sum
(
-
(
self
.
residual
/
self
.
sigma
)
**
2
/
2
-
np
.
log
(
2
*
np
.
pi
*
self
.
sigma
)
/
2
)
return
log_l
def
__get_sigma
(
self
):
@property
def
sigma
(
self
):
"""
This checks if sigma has been set in parameters. If so, that value
will be used. Otherwise, the attribute sigma is used. The logic is
that if sigma is not in parameters the attribute is used which was
given at init (i.e. the known sigma as either a float or array).
"""
return
self
.
parameters
.
get
(
'
sigma
'
,
self
.
sigma
)
return
self
.
parameters
.
get
(
'
sigma
'
,
self
.
_
sigma
)
def
__summed_log_likelihood
(
self
,
sigma
):
return
-
0.5
*
(
np
.
sum
((
self
.
residual
/
sigma
)
**
2
)
+
self
.
n
*
np
.
log
(
2
*
np
.
pi
*
sigma
**
2
))
@sigma.setter
def
sigma
(
self
,
sigma
):
if
isinstance
(
sigma
,
float
)
or
len
(
sigma
)
==
self
.
n
:
self
.
_sigma
=
sigma
else
:
raise
ValueError
(
'
Sigma must be either float or array-like x.
'
)
class
PoissonLikelihood
(
Analytical1DLikelihood
):
...
...
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