Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Marc Arene
bilby
Commits
7bfc4d28
Commit
7bfc4d28
authored
6 years ago
by
Virginia d'Emilio
Committed by
Moritz Huebner
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Revert "adding functions"
This reverts commit
be6a6de7
.
parent
da94f005
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/other_examples/multidimensional_gaussian.py
+80
-0
80 additions, 0 deletions
examples/other_examples/multidimensional_gaussian.py
with
80 additions
and
0 deletions
examples/other_examples/multidimensional_gaussian.py
0 → 100644
+
80
−
0
View file @
7bfc4d28
#!/usr/bin/env python
"""
Testing the recovery of a multi-dimensional
Gaussian with zero mean and unit variance
"""
from
__future__
import
division
import
bilby
import
numpy
as
np
# A few simple setup steps
label
=
"
multidim_gaussian
"
outdir
=
"
outdir
"
# Generating simulated data: generating n-dim Gaussian
dim
=
5
mean
=
np
.
zeros
(
dim
)
cov
=
np
.
ones
((
dim
,
dim
))
data
=
np
.
random
.
multivariate_normal
(
mean
,
cov
,
100
)
class
MultidimGaussianLikelihood
(
bilby
.
Likelihood
):
"""
A multivariate Gaussian likelihood
with known analytic solution.
Parameters
----------
data: array_like
The data to analyse
dim: int
The number of dimensions
"""
def
__init__
(
self
,
data
,
dim
):
self
.
dim
=
dim
self
.
data
=
np
.
array
(
data
)
self
.
N
=
len
(
data
)
self
.
parameters
=
{}
def
log_likelihood
(
self
):
mu
=
np
.
array
(
[
self
.
parameters
[
"
mu_{0}
"
.
format
(
i
)]
for
i
in
range
(
self
.
dim
)]
)
sigma
=
np
.
array
(
[
self
.
parameters
[
"
sigma_{0}
"
.
format
(
i
)]
for
i
in
range
(
self
.
dim
)]
)
p
=
np
.
array
([(
self
.
data
[
n
,
:]
-
mu
)
/
sigma
for
n
in
range
(
self
.
N
)])
return
np
.
sum
(
-
0.5
*
(
np
.
sum
(
p
**
2
)
+
self
.
N
*
np
.
log
(
2
*
np
.
pi
*
sigma
**
2
))
)
likelihood
=
MultidimGaussianLikelihood
(
data
,
dim
)
priors
=
bilby
.
core
.
prior
.
PriorDict
()
priors
.
update
(
{
"
mu_{0}
"
.
format
(
i
):
bilby
.
core
.
prior
.
Uniform
(
-
5
,
5
,
"
mu
"
)
for
i
in
range
(
dim
)
}
)
priors
.
update
(
{
"
sigma_{0}
"
.
format
(
i
):
bilby
.
core
.
prior
.
LogUniform
(
0.2
,
5
,
"
sigma
"
)
for
i
in
range
(
dim
)
}
)
# And run sampler
# The plot arg produces trace_plots useful for diagnostics
result
=
bilby
.
run_sampler
(
likelihood
=
likelihood
,
priors
=
priors
,
sampler
=
"
dynesty
"
,
npoints
=
500
,
walks
=
10
,
outdir
=
outdir
,
label
=
label
,
plot
=
True
,
)
result
.
plot_corner
()
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