Commit 486fda18 authored by Philipp Arras's avatar Philipp Arras
Browse files

Remove draw_sample for KL.metric

The information theoretic interpretation of drawing samples from the
metric of the KL samples is not clear. This may be the reason why it was
not documented before.
parent 81e0af93
Pipeline #96698 passed with stages
in 11 minutes and 47 seconds
...@@ -38,9 +38,6 @@ class _KLMetric(EndomorphicOperator): ...@@ -38,9 +38,6 @@ class _KLMetric(EndomorphicOperator):
self._check_input(x, mode) self._check_input(x, mode)
return self._KL.apply_metric(x) return self._KL.apply_metric(x)
def draw_sample(self, from_inverse=False):
return self._KL._metric_sample(from_inverse)
def _get_lo_hi(comm, n_samples): def _get_lo_hi(comm, n_samples):
ntask, rank, _ = utilities.get_MPI_params_from_comm(comm) ntask, rank, _ = utilities.get_MPI_params_from_comm(comm)
...@@ -260,22 +257,3 @@ class MetricGaussianKL(Energy): ...@@ -260,22 +257,3 @@ class MetricGaussianKL(Energy):
yield s yield s
if self._mirror_samples: if self._mirror_samples:
yield -s yield -s
def _metric_sample(self, from_inverse=False):
if from_inverse:
raise NotImplementedError()
s = ('This draws from the Hamiltonian used for evaluation and does '
' not take point_estimates into accout. Make sure that this '
'is your intended use.')
logger.warning(s)
lin = Linearization.make_var(self.position, True)
samp = []
sseq = random.spawn_sseq(self._n_samples)
for i, s in enumerate(self._local_samples):
s = _modify_sample_domain(s, self._hamiltonian.domain)
with random.Context(sseq[self._lo+i]):
tmp = self._hamiltonian(lin+s).metric.draw_sample(from_inverse=False)
if self._mirror_samples:
tmp = tmp + self._hamiltonian(lin-s).metric.draw_sample(from_inverse=False)
samp.append(tmp)
return utilities.allreduce_sum(samp, self._comm)/self.n_eff_samples
Supports Markdown
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