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
cb1b11af
Commit
cb1b11af
authored
6 years ago
by
Gregory Ashton
Browse files
Options
Downloads
Patches
Plain Diff
Update example to work with changes in the HierarchicalLikelihood
parent
0fa784e5
No related branches found
No related tags found
1 merge request
!41
Add hyper-parameter likelihood
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/other_examples/hyper_parameter_example.py
+5
-28
5 additions, 28 deletions
examples/other_examples/hyper_parameter_example.py
with
5 additions
and
28 deletions
examples/other_examples/hyper_parameter_example.py
+
5
−
28
View file @
cb1b11af
...
...
@@ -69,38 +69,15 @@ for i in range(Nevents):
samples
.
append
(
result
.
samples
)
# Now run the hyperparameter inference
def
run_prior
(
val
):
if
np
.
all
(
val
>
-
10
)
&
np
.
all
(
val
<
10
):
return
1
/
20.
else
:
return
0
def
hyper_prior
(
val
,
mu_m
,
sigma_m
):
return
np
.
exp
(
-
(
mu_m
-
val
)
**
2
/
2
/
sigma_m
**
2
)
/
np
.
sqrt
(
2
*
np
.
pi
*
sigma_m
**
2
)
def
log_run_prior
(
val
):
if
np
.
all
(
val
>
-
10
)
&
np
.
all
(
val
<
10
):
return
len
(
val
)
*
-
np
.
log
(
20
)
else
:
return
0
def
log_hyper_prior
(
val
,
mu_m
,
sigma_m
):
res
=
val
-
mu_m
return
-
0.5
*
(
np
.
sum
((
res
/
sigma_m
)
**
2
)
+
len
(
val
)
*
np
.
log
(
2
*
np
.
pi
*
sigma_m
**
2
))
run_prior
=
tupak
.
prior
.
Uniform
(
minimum
=-
10
,
maximum
=
10
,
name
=
'
mu_m
'
)
hyper_prior
=
tupak
.
prior
.
Gaussian
(
mu
=
0
,
sigma
=
1
,
name
=
'
hyper
'
)
hp_likelihood
=
tupak
.
likelihood
.
HyperparameterLikelihood
(
samples
,
log_
hyper_prior
,
log_
run_prior
,
mu
_m
=
None
,
sigma
_m
=
None
)
samples
,
hyper_prior
,
run_prior
,
mu
=
None
,
sigma
=
None
)
hp_priors
=
dict
(
mu
_m
=
tupak
.
prior
.
Uniform
(
-
10
,
10
,
'
mu
_m
'
,
'
$\mu_m$
'
),
sigma
_m
=
tupak
.
prior
.
Uniform
(
0
,
10
,
'
sigma
_m
'
,
'
$\sigma_m$
'
))
mu
=
tupak
.
prior
.
Uniform
(
-
10
,
10
,
'
mu
'
,
'
$\mu_m$
'
),
sigma
=
tupak
.
prior
.
Uniform
(
0
,
10
,
'
sigma
'
,
'
$\sigma_m$
'
))
# And run sampler
...
...
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