Commit 8a649ec3 authored by Theo Steininger's avatar Theo Steininger
Browse files

improved SimpleLikelihood

parent c4937fa9
# -*- 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 /=
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)
right = diff
return -0.5 * diff.conjugate().vdot(right)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment