Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
IMAGINE
Commits
8a649ec3
Commit
8a649ec3
authored
Nov 17, 2017
by
Theo Steininger
Browse files
improved SimpleLikelihood
parent
c4937fa9
Changes
1
Hide whitespace changes
Inline
Side-by-side
imagine/likelihoods/simple_likelihood/simple_likelihood.py
View file @
8a649ec3
# -*- coding: utf-8 -*-
import
numpy
as
np
from
imagine.likelihoods.likelihood
import
Likelihood
class
SimpleLikelihood
(
Likelihood
):
def
__init__
(
self
,
measured_data
):
def
__init__
(
self
,
measured_data
,
data_covariance_operator
=
None
):
self
.
measured_data
=
measured_data
self
.
data_covariance_operator
=
data_covariance_operator
def
__call__
(
self
,
observable
):
shape
=
observable
.
shape
data
=
self
.
measured_data
.
val
.
get_full_data
()
obs
=
observable
.
val
.
get_full_data
()
quadratic_diff
=
((
data
-
obs
).
conjugate
()
*
(
data
-
obs
)).
sum
()
quadratic_diff
/=
np
.
prod
(
shape
)
obs_mean
=
observable
.
ensemble_mean
().
val
.
get_full_data
()
return
-
quadratic_diff
diff
=
data
-
obs_mean
if
self
.
data_covariance_operator
is
not
None
:
right
=
self
.
data_covariance_operator
.
inverse_times
(
diff
)
else
:
right
=
diff
return
-
0.5
*
diff
.
conjugate
().
vdot
(
right
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment