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
5f5879cd
Commit
5f5879cd
authored
6 years ago
by
Moritz Huebner
Browse files
Options
Downloads
Plain Diff
Merge branch 'improve-cpnest-prior-sampling' into 'master'
improve cpnest prior sampling See merge request
!414
parents
99425cde
47eed02a
No related branches found
No related tags found
1 merge request
!414
improve cpnest prior sampling
Pipeline
#55470
passed
6 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/sampler/cpnest.py
+13
-11
13 additions, 11 deletions
bilby/core/sampler/cpnest.py
with
13 additions
and
11 deletions
bilby/core/sampler/cpnest.py
+
13
−
11
View file @
5f5879cd
...
...
@@ -49,14 +49,17 @@ class Cpnest(NestedSampler):
def
run_sampler
(
self
):
from
cpnest
import
model
as
cpmodel
,
CPNest
from
cpnest.parameter
import
LivePoint
class
Model
(
cpmodel
.
Model
):
"""
A wrapper class to pass our log_likelihood into cpnest
"""
def
__init__
(
self
,
names
,
bound
s
):
def
__init__
(
self
,
names
,
prior
s
):
self
.
names
=
names
self
.
bounds
=
bounds
self
.
_check_bounds
()
self
.
priors
=
priors
self
.
bounds
=
[
[
self
.
priors
[
key
].
minimum
,
self
.
priors
[
key
].
maximum
]
for
key
in
self
.
names
]
@staticmethod
def
log_likelihood
(
x
,
**
kwargs
):
...
...
@@ -68,15 +71,14 @@ class Cpnest(NestedSampler):
theta
=
[
x
[
n
]
for
n
in
self
.
search_parameter_keys
]
return
self
.
log_prior
(
theta
)
def
_check_bounds
(
self
):
for
bound
in
self
.
bounds
:
if
not
all
(
np
.
isfinite
(
bound
)):
raise
ValueError
(
'
CPNest requires priors to have finite bounds.
'
)
def
new_point
(
self
):
"""
Draw a point from the prior
"""
point
=
LivePoint
(
self
.
names
,
[
self
.
priors
[
name
].
sample
()
for
name
in
self
.
names
])
return
point
bounds
=
[[
self
.
priors
[
key
].
minimum
,
self
.
priors
[
key
].
maximum
]
for
key
in
self
.
search_parameter_keys
]
model
=
Model
(
self
.
search_parameter_keys
,
bounds
)
model
=
Model
(
self
.
search_parameter_keys
,
self
.
priors
)
out
=
CPNest
(
model
,
**
self
.
kwargs
)
out
.
run
()
...
...
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