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
b26a5a98
Commit
b26a5a98
authored
5 years ago
by
Moritz Huebner
Browse files
Options
Downloads
Plain Diff
Merge branch 'prior_weights' into 'master'
Prior weights See merge request
!441
parents
dd91b4c6
122a9ed0
No related branches found
No related tags found
1 merge request
!441
Prior weights
Pipeline
#58460
passed
5 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bilby/core/result.py
+42
-0
42 additions, 0 deletions
bilby/core/result.py
with
42 additions
and
0 deletions
bilby/core/result.py
+
42
−
0
View file @
b26a5a98
...
...
@@ -1184,6 +1184,48 @@ class Result(object):
"
keyword argument, e.g.
"
+
caller_func
.
__name__
+
"
(outdir=
'
.
'
)
"
)
return
outdir
def
get_weights_by_new_prior
(
self
,
old_prior
,
new_prior
,
prior_names
=
None
):
"""
Calculate a list of sample weights based on the ratio of new to old priors
Parameters
----------
old_prior: PriorDict,
The prior used in the generation of the original samples.
new_prior: PriorDict,
The prior to use to reweight the samples.
prior_names: list
A list of the priors to include in the ratio during reweighting.
Returns
-------
weights: array-like,
A list of sample weights.
"""
weights
=
[]
# Shared priors - these will form a ratio
if
prior_names
is
not
None
:
shared_parameters
=
{
key
:
self
.
posterior
[
key
]
for
key
in
new_prior
if
key
in
old_prior
and
key
in
prior_names
}
else
:
shared_parameters
=
{
key
:
self
.
posterior
[
key
]
for
key
in
new_prior
if
key
in
old_prior
}
parameters
=
[{
key
:
self
.
posterior
[
key
][
i
]
for
key
in
shared_parameters
.
keys
()}
for
i
in
range
(
len
(
self
.
posterior
))]
for
i
in
range
(
len
(
self
.
posterior
)):
weight
=
1
for
prior_key
in
shared_parameters
.
keys
():
val
=
self
.
posterior
[
prior_key
][
i
]
weight
*=
new_prior
.
evaluate_constraints
(
parameters
[
i
])
weight
*=
new_prior
[
prior_key
].
prob
(
val
)
/
old_prior
[
prior_key
].
prob
(
val
)
weights
.
append
(
weight
)
return
weights
def
plot_multiple
(
results
,
filename
=
None
,
labels
=
None
,
colours
=
None
,
save
=
True
,
evidences
=
False
,
**
kwargs
):
...
...
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