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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
IMAGINE
Commits
8cb12c47
Commit
8cb12c47
authored
Oct 30, 2017
by
Theo Steininger
Browse files
Fixed a bug in EnsembleLikelihood
parent
7778ae29
Changes
1
Hide whitespace changes
Inline
Side-by-side
imagine/likelihoods/ensemble_likelihood/ensemble_likelihood.py
View file @
8cb12c47
...
...
@@ -50,16 +50,17 @@ class EnsembleLikelihood(Likelihood):
u_val
=
obs_val
-
obs_mean
# compute quantities for OAS estimator
mu
=
np
.
vdot
(
u_val
,
u_val
)
*
weight
/
k
mu
=
np
.
vdot
(
u_val
,
u_val
)
*
weight
/
k
/
n
self
.
logger
.
debug
(
"mu: %f"
%
mu
)
alpha
=
(
np
.
einsum
(
u_val
,
[
0
,
1
],
u_val
,
[
2
,
1
])
**
2
).
sum
()
alpha
/=
k
*
2
# correct the volume factor: one factor comes from the internal scalar
# product and one from the trace
alpha
*=
weight
**
2
numerator
=
(
1
-
2.
/
n
)
*
alpha
+
mu
**
2
denominator
=
(
k
+
1
-
2.
/
n
)
*
(
alpha
-
(
mu
**
2
)
/
n
)
numerator
=
(
1
-
2.
/
n
)
*
alpha
+
(
mu
*
n
)
*
*
2
denominator
=
(
k
+
1
-
2.
/
n
)
*
(
alpha
-
(
(
mu
*
n
)
*
*
2
)
/
n
)
if
denominator
==
0
:
rho
=
1
...
...
@@ -79,7 +80,7 @@ class EnsembleLikelihood(Likelihood):
"DiagonalOperator."
)
A_bare_diagonal
=
data_covariance_operator
.
diagonal
(
bare
=
True
)
A_bare_diagonal
.
val
+=
rho
*
mu
/
n
A_bare_diagonal
.
val
+=
rho
*
mu
A
=
DiagonalOperator
(
domain
=
data_covariance_operator
.
domain
,
diagonal
=
A_bare_diagonal
,
...
...
@@ -94,9 +95,6 @@ class EnsembleLikelihood(Likelihood):
np
.
einsum
(
u_val
.
conjugate
(),
[
0
,
1
],
a_u_val
,
[
2
,
1
])
*
weight
)
middle
=
np
.
linalg
.
inv
(
middle
)
# result_array = np.zeros(k)
# for i in xrange(k):
# c = measured_data - obs_val[i]
c
=
measured_data
-
obs_mean
# assuming that A == A^dagger, this can be shortend
...
...
@@ -117,14 +115,14 @@ class EnsembleLikelihood(Likelihood):
second_summand_val
=
np
.
einsum
(
middle
,
[
0
,
1
],
u_a_c_val
,
[
1
])
second_summand_val
=
np
.
einsum
(
a_u_val
,
[
0
,
1
],
second_summand_val
,
[
0
])
second_summand_val
*=
-
1
#
second_summand_val *= -1
second_summand
=
first_summand
.
copy_empty
()
second_summand
.
val
=
second_summand_val
result_1
=
-
c
.
vdot
(
first_summand
)
result_1
=
c
.
vdot
(
first_summand
)
result_2
=
-
c
.
vdot
(
second_summand
)
result
=
result_1
+
result_2
self
.
logger
.
info
(
"Calculated (%s): %f + %f = %f"
%
result
=
-
(
result_1
+
result_2
)
self
.
logger
.
info
(
"Calculated (%s):
-(
%f + %f
)
= %f"
%
(
self
.
observable_name
,
result_1
,
result_2
,
result
))
# result_array[i] = result
# total_result = result_array.mean()
...
...
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