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
Merge requests
!716
Resolve "Add multivariate gaussian to core likelihood"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add multivariate gaussian to core likelihood"
455-add-multivariate-gaussian-to-core-likelihood
into
master
Overview
4
Commits
6
Pipelines
4
Changes
3
Merged
Moritz Huebner
requested to merge
455-add-multivariate-gaussian-to-core-likelihood
into
master
5 years ago
Overview
4
Commits
6
Pipelines
4
Changes
3
Expand
Closes
#455 (closed)
Edited
5 years ago
by
Moritz Huebner
0
0
Merge request reports
Compare
master
version 2
ab133708
5 years ago
version 1
1c9cf801
5 years ago
master (base)
and
latest version
latest version
3d580541
6 commits,
5 years ago
version 2
ab133708
2 commits,
5 years ago
version 1
1c9cf801
1 commit,
5 years ago
3 files
+
147
−
65
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
bilby/core/likelihood.py
+
64
−
0
Options
@@ -3,6 +3,7 @@ import copy
import
numpy
as
np
from
scipy.special
import
gammaln
from
scipy.stats
import
multivariate_normal
from
.utils
import
infer_parameters_from_function
@@ -401,6 +402,69 @@ class StudentTLikelihood(Analytical1DLikelihood):
self
.
_nu
=
nu
class
AnalyticalMultidimensionalCovariantGaussian
(
Likelihood
):
"""
A multivariate Gaussian likelihood
with known analytic solution.
Parameters
----------
mean: array_like
Array with the mean values of distribution
cov: array_like
The ndim*ndim covariance matrix
"""
def
__init__
(
self
,
mean
,
cov
):
self
.
cov
=
np
.
atleast_2d
(
cov
)
self
.
mean
=
np
.
atleast_1d
(
mean
)
self
.
sigma
=
np
.
sqrt
(
np
.
diag
(
self
.
cov
))
self
.
pdf
=
multivariate_normal
(
mean
=
self
.
mean
,
cov
=
self
.
cov
)
parameters
=
{
"
x{0}
"
.
format
(
i
):
0
for
i
in
range
(
self
.
dim
)}
super
(
AnalyticalMultidimensionalCovariantGaussian
,
self
).
__init__
(
parameters
=
parameters
)
@property
def
dim
(
self
):
return
len
(
self
.
cov
[
0
])
def
log_likelihood
(
self
):
x
=
np
.
array
([
self
.
parameters
[
"
x{0}
"
.
format
(
i
)]
for
i
in
range
(
self
.
dim
)])
return
self
.
pdf
.
logpdf
(
x
)
class
AnalyticalMultidimensionalBimodalCovariantGaussian
(
Likelihood
):
"""
A multivariate Gaussian likelihood
with known analytic solution.
Parameters
----------
mean_1: array_like
Array with the mean value of the first mode
mean_2: array_like
Array with the mean value of the second mode
cov: array_like
"""
def
__init__
(
self
,
mean_1
,
mean_2
,
cov
):
self
.
cov
=
np
.
atleast_2d
(
cov
)
self
.
sigma
=
np
.
sqrt
(
np
.
diag
(
self
.
cov
))
self
.
mean_1
=
np
.
atleast_1d
(
mean_1
)
self
.
mean_2
=
np
.
atleast_1d
(
mean_2
)
self
.
pdf_1
=
multivariate_normal
(
mean
=
self
.
mean_1
,
cov
=
self
.
cov
)
self
.
pdf_2
=
multivariate_normal
(
mean
=
self
.
mean_2
,
cov
=
self
.
cov
)
parameters
=
{
"
x{0}
"
.
format
(
i
):
0
for
i
in
range
(
self
.
dim
)}
super
(
AnalyticalMultidimensionalBimodalCovariantGaussian
,
self
).
__init__
(
parameters
=
parameters
)
@property
def
dim
(
self
):
return
len
(
self
.
cov
[
0
])
def
log_likelihood
(
self
):
x
=
np
.
array
([
self
.
parameters
[
"
x{0}
"
.
format
(
i
)]
for
i
in
range
(
self
.
dim
)])
return
-
np
.
log
(
2
)
+
np
.
logaddexp
(
self
.
pdf_1
.
logpdf
(
x
),
self
.
pdf_2
.
logpdf
(
x
))
class
JointLikelihood
(
Likelihood
):
def
__init__
(
self
,
*
likelihoods
):
"""
Loading