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
195e300d
Commit
195e300d
authored
6 years ago
by
Matthew Pitkin
Browse files
Options
Downloads
Patches
Plain Diff
likelihood.py: add pymc3_likelihood method for PoissonLikelihood class
parent
76509005
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!139
Add PyMC3 sampler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tupak/core/likelihood.py
+24
-0
24 additions, 0 deletions
tupak/core/likelihood.py
with
24 additions
and
0 deletions
tupak/core/likelihood.py
+
24
−
0
View file @
195e300d
...
...
@@ -236,3 +236,27 @@ class PoissonLikelihood(Likelihood):
-
self
.
sumlogfactorial
)
else
:
raise
ValueError
(
"
Poisson rate function returns wrong value type!
"
)
def
pymc3_likelihood
(
self
,
sampler
):
from
tupak.core.sampler
import
Sampler
if
not
isinstance
(
sampler
,
Sampler
):
raise
ValueError
(
"'
sampler
'
is not a Sampler class
"
)
try
:
samplername
=
sampler
.
external_sampler
.
__name__
except
ValueError
:
raise
ValueError
(
"
Sampler
'
s
'
external_sampler
'
has not been initialised
"
)
if
samplername
!=
'
pymc3
'
:
raise
ValueError
(
"
Only use this class method for PyMC3 sampler
"
)
for
key
in
sampler
.
pymc3_priors
:
if
key
not
in
self
.
function_keys
:
raise
ValueError
(
"
Prior key
'
{}
'
is not a function key!
"
.
format
(
key
))
# get rate function
rate
=
self
.
function
(
self
.
x
,
**
sampler
.
pymc3_priors
)
return
sampler
.
external_sampler
.
Poisson
(
'
likelihood
'
,
mu
=
rate
,
observed
=
self
.
y
)
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